homepage Welcome to WebmasterWorld Guest from 50.17.162.174
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Searching Two Mysql Tables
matthewamzn




msg:3875307
 4:50 pm on Mar 20, 2009 (gmt 0)

How can I combine two searches from different tables into one query?

$query_one = "SELECT * FROM `v_inv` WHERE MATCH (color,make,model,intcolor,category) AGAINST ('{$search}') AND public = 1 ORDER BY date";
$query_two = "SELECT * FROM `v_pvi` WHERE MATCH (color,make,model,intcolor,category) AGAINST ('{$search}') AND public = 1 ORDER BY date";

 

LifeinAsia




msg:3875311
 5:00 pm on Mar 20, 2009 (gmt 0)

SELECT *
FROM `v_pvi`
WHERE MATCH (color,make,model,intcolor,category) AGAINST ('{$search}') AND public = 1
UNION
SELECT *
FROM `v_pvi`
WHERE MATCH (color,make,model,intcolor,category) AGAINST ('{$search}') AND public = 1

The field names must be identical in each table. Otherwise, just select the fields that do have identical names (or use aliases).

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved