jurgen Posted August 13, 2003 Share Posted August 13, 2003 $query = \"SELECT * FROM intranet_opdrachten AND intranet_bedrijven WHERE omschrijving OR opdrachtgever LIKE \'%$zoeken%\'\"; This is not the right query to search in both tables (intranet_opdrachten AND intranet_bedrijven). Hopefully someone knows the solution to this problem. I can search in one table, but two seems to be difficult. Thank you! Link to comment https://forums.phpfreaks.com/topic/889-search-multiple-tables-mysql-database/ Share on other sites More sharing options...
rhysmeister Posted August 13, 2003 Share Posted August 13, 2003 \"SELECT * FROM intranet_opdrachten LEFT JOIN intranet_bedrijven ON intranet_opdrachten.id=intranet_bedrijven.id WHERE intranet_opdrachten.omschrijving OR intranet_opdrachten.opdrachtgever OR intranet_bedrijven.omschrijving OR intranet_bedrijven.opdrachtgever LIKE \'%$zoeken%\'\"; Something like this should do. I haven\'t had time to test it so can\'t be 100% sure. You need to join the two tables by a appropriate field. Do a little bit of research on table joins and you should be ok. Hope this helps. Link to comment https://forums.phpfreaks.com/topic/889-search-multiple-tables-mysql-database/#findComment-2959 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.