php mysql search in 2 columns in 2 tables.
Posted
by andrew fishwick
on Stack Overflow
See other posts from Stack Overflow
or by andrew fishwick
Published on 2010-05-16T15:26:06Z
Indexed on
2010/05/16
15:30 UTC
Read the original article
Hit count: 203
Hey,
I have two tables in one DB, one called Cottages and one called Hotels. In both tables they have the same named fields.
I basically have a search bar that i want it to search in both of the fields in both of the tables. (the two fields being called "Name" and "Location"
SO far I have
$sql = mysql_query("SELECT * FROM Cottages WHERE Name LIKE '%$term%' or Location LIKE '%$term%' LIMIT 0, 30");
But this only searches the Cottages table, how can I make it search both the cottages and hotel tables?
Andy
© Stack Overflow or respective owner