homepage Welcome to WebmasterWorld Guest from 54.227.41.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Search query multiple tables? (PHP, MySQL)
Website Search Engine Series...
alcheme




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

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




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

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

alcheme




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

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);

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved