选择使用jquery使用单选按钮查询多个表

I'm building a comics website, which has two subsites: Comics and Artwork. Comics and Artwork are stored in two separate tables.

I have a search function that allows the user to search for an image.

I'd like to give them an option to choose to search for only comics, only artwork, or both.

enter image description here

I have the following javascript which I believe should be working:

    <script type="text/javascript">

        function search(searchString) {     
           var site = $("#site").val();
           $.get("./scripts/search.php", {_input : searchString, _site : site},
                function(returned_data) {
                    $("#output").html(returned_data);
                }
            );
        }

        function searchChoice(choice) {     
           $.get("./scripts/search.php", {_choice : choice}
           );
        }

</script>

And the following HTML:

    <!--Search filtering for comics, artwork, or both-->
<span class="search"><b>Search for: </b> </span>

<div class="btn-group" data-toggle="buttons-radio">
<span class="search">
    <button type="button" class="btn" id="comics" onclick="searchChoice(this.id)">Comics</button> 
    <button type="button" class="btn" id="artwork" onclick="searchChoice(this.id)">Artwork</button> 
    <button type="button" class="btn" id="all" onclick="searchChoice(this.id)">All</button> 
</span>
</div>

<br/>
<br/>

<!--Search functionality-->
<span class="search">
    <input type="text" onkeyup="search(this.value)" name="input" value="" />
    <input id="site" type="hidden" value="<?php echo $site; ?>">
</span>

<br />
<span id="output"><span class="sidebarimages">  </span></span>

My question is here with the PHP in querying TWO tables:

Am I doing the JOIN correctly?

$input = (isset($_GET['_input']) ? ($_GET['_input']) : 0); 
$choice = (isset($_GET['_choice']) ? ($_GET['_choice']) : "all");
$site = (isset($_GET['site']) ? ($_GET['site']) : null);


if ($choice == "artwork") {
    $sql = "SELECT id, title, thumb FROM artwork";
    $thumbpath = "./images/Artwork/ArtThumbnails/";
}
else if ($choice == "comics") {
    $sql = "SELECT id, title, thumb FROM comics";
    $thumbpath = "./images/Comics/ComicThumbnails/";
}
else {
    $sql = "SELECT id, title, thumb FROM comics 
            UNION 
            SELECT id, title, thumb FROM artwork";
    $thumbpath = "./images/AllThumbnails/";
}


$imgpaths = $mysqli->query($sql);
mysqli_close($mysqli);

Thanks!

No, you're not stating any conditions for joining the 2 tables, also in the case of looking in both tables, you may want to consider using UNION instead, as in:

SELECT * FROM comics
UNION
SELECT * FROM artwork

To use JOIN function you need relations between tables (foreign keys connecting one to another)