union not allowed

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jeiman
Forum Newbie
Posts: 8
Joined: Wed Jul 17, 2002 5:24 am
Contact:

union not allowed

Post by jeiman »

I have 3 tables where I want to search a result in both 3 tables. The problem is I just realize my MySql version 3, not allowed me to use UNION syntax. Is there any other way where I can get the result as same as UNION without using UNIon command??
Any help please..
LM
Forum Newbie
Posts: 2
Joined: Mon Dec 09, 2002 7:23 am

Post by LM »

You can use tree select queries.

If you need a specific order you can insert the results of the tree queries in a temporary table and perform a select on this temporary table.
jeiman
Forum Newbie
Posts: 8
Joined: Wed Jul 17, 2002 5:24 am
Contact:

Post by jeiman »

Thanks LM,

But then I don't really know the tree select query. Can you show me how. My 3 tables are products, specifications and companies. My query using UNION is:

$word_var = "% any_words %";

"SELECT id, name FROM specifications
WHERE name LIKE '" . $word_var . "'
OR description LIKE '" . $word_var . "'
UNION
SELECT id, name FROM products
WHERE name LIKE '" . $word_var . "'
OR overview LIKE '" . $word_var . "'
UNION
SELECT id, name FROM companies
WHERE name LIKE '" . $word_var . "'
OR info LIKE '" . $word_var . "'
OR address LIKE LIKE '" . $word_var . "' ";

Can you please convert that query into tree select query. Your help is really appreciated. Thank you
Post Reply