Welcome to WebmasterWorld Guest from 23.22.250.113

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Search query multiple tables? (PHP, MySQL)

Website Search Engine Series...

     

alcheme

11:29 pm on Jan 8, 2005 (gmt 0)

10+ Year Member



How can I search multiple tables & databases?

Current table: directory
Additional table: list

------> Start Code

$db=mysql_connect ("localhost", "******", "*******") or die ('I cannot connect to the database because: ' . mysql_error());

mysql_select_db ("****_DBNAME",$db);

$sql= mysql_query("SELECT wname, url, title, keywords, description, city, country, category FROM directory WHERE city LIKE '%$search%' wname LIKE '%$search%' title LIKE '%$search%' keywords LIKE '%$search%' description LIKE '%$search%' country LIKE '%$search%' category LIKE '%$search%' url LIKE '%$search%'", $db);

------> End Code

Any ideas?

I'll post the final solution when there is one :-)

~Shane

storevalley

11:35 pm on Jan 8, 2005 (gmt 0)

10+ Year Member



To query multiple tables, use a join [dev.mysql.com].

alcheme

12:27 am on Jan 9, 2005 (gmt 0)

10+ Year Member



For example... Just like this?

$sql= mysql_query("SELECT wname, url, title, keywords, description, city, country, category FROM directory WHERE city LIKE '%$search%' wname LIKE '%$search%' title LIKE '%$search%' keywords LIKE '%$search%' description LIKE '%$search%' country LIKE '%$search%' category LIKE '%$search%' url LIKE '%$search%' JOIN SELECT * FROM list WHERE city LIKE '%$search%'", $db);

 

Featured Threads

Hot Threads This Week

Hot Threads This Month