RE: [PHP] Search a word in multiple tables
| From: | Murray @ PlanetThoughtful | Date: | Fri, 05 Nov 2004 12:45:33 +0000 |
| Subject: | RE: [PHP] Search a word in multiple tables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201280@lists.php.net to get a copy of this message | ||
> Hi,
> How can i search a specific word in 2 tables
> I use this but it is not working
>
> sql = "SELECT a.product_id, a.".select_language('product_name_en',
> 'product_name_fr').", b.brand_name FROM products_accessories as a, brands
> as b
> WHERE (a.".select_language('product_name_en',
> 'product_name_fr')." LIKE '%".$word."%' OR b.brand_name
> LIKE
> '%".$word."%')";
> $result= mysql_query($sql);
Are you using MySQL? If so, depending on which version you have, it might be
worth checking out UNION queries.
http://dev.mysql.com/doc/mysql/en/UNION.html
Much warmth,
Murray
http://www.planetthoughtful.org
Building a thoughtful planet,
One quirky comment at a time.