
October 31st, 2003, 07:06 PM
|
|
|
|
Join Date: Apr 2007
Posts: 158
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
Search multiple tables with one keyword
I have 4 tables in a db. Each contains a category field, however the tables are not connected or linked by these fields, as they hold different types of info. The tables are "bands", "musicians", "songwriters", & "otherposts".
If possible, I'd like to use one search page & query to query all 4 tables at once, by category. So on a search page, the user can select Bands, Musicians, Songwriters, or Other, then hit the submit/search button. The query would then bring up all the db entries that match the category the user chose. I've tried a few queries but get no results. I didn't think this would be considered a join, since the tables are basically unrelated and I dont need info from all the tables at one time.
My basic form...
<form action=search.php method=post>
<input type=radio name=search_cat value=bands>Bands<br>
<input type=radio name=search_cat value=musicians>Musicians<br>
<input type=radio name=search_cat value=songwriters>Songwriters<br>
<input type=radio name=search_cat value=other>Other
And the query I tried...
$query=("SELECT * FROM bands.category,musicians.category,songriters.categ ory,otherposts.category WHERE category LIKE '$search_cat'");
I also tried a few variations on this, and I'm probably way off base.
|