I'm trying to have my websites search box be able to search multiple tables in one query.
So if a user searches for the users display_name
which is stored in ptb_profiles
they get any users with the matching name or if they search by nationality which is stored in ptb_stats
they get all the users with that nationality displayed.
When i did this originally by using SELECT * FROM ptb_users, ptb_stats, ptb_profiles
I got duplicate search results and the same results were being displayed multiple times, so I tried to do avoid this and have each result only displayed once by Grouping and using union all but that didnt work.
now ive tried this:
$query_for_result=mysql_query("SELECT display_name, location, gender, contact_number FROM ptb_profiles WHERE display_name LIKE '%".$query."%' OR location LIKE '%".$query."%' OR gender LIKE '%".$query."%' OR contact_number LIKE '%".$query."%' JOIN SELECT email, subscription FROM ptb_users WHERE email like '%".$query."%' OR subscription like '%".$query."%' JOIN SELECT nationality, hobbies, local_station FROM ptb_stats WHERE nationality like '%".$query."%' OR hobbies like '%".$query."%' OR local_station like '%".$query."%'
LIMIT 5");
but this just brings up the following error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /Applications/XAMPP/xamppfiles/htdocs/PTB1/includes/mod_sidebar/search.php on line 31
Can someone please tell me where I'm going wrong?