I don't think there's anything conceptually wrong with what you're doing. Most relational databases let you UNION together many more than 3 queries; I assume MySQL also allows this.
I don't see any obvious syntax error jumping out at me. What error message are you getting? I suspect that you are not lining up the three queries correctly. The datatypes of the columns have to be consistent: for instance, if the first column is numeric in the first query, the first column in the other queries have to be numeric too. Is it possible that the datatypes of the columns in the third query don't match their counterparts in the first two queries? I see that the column names are the same in each query but if, for example, page_id in the url_pages table is character while the page_id columns returned by the first two queries are numeric, you would almost certainly have a problem. Rhino ----- Original Message ----- From: "leegold" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 22, 2004 11:14 PM Subject: Union query help > Is this possible? Is it possible to have three queries in a UNION? Sorry > about the PHP in there. I just wanted to know if this is allowed? If > only the 1st two queries it works OK, add the 3rd and it breaks. How can > I accomplish this? Thanks. Lee G. I'm using 4.1.3beta > > $result = mysql_query("(SELECT p.page_id, p.page_url AS url, p.title AS > title, > p.descrip AS descrip > FROM page p, word w, occurrence o > WHERE p.page_id = o.page_id AND > w.word_id = o.word_id AND > w.word_word LIKE '%$keyword%') > UNION > (SELECT p.page_id, p.page_url AS url, p.title AS > title, > p.descrip AS descrip > FROM page p > WHERE p.descrip LIKE '%$keyword%' OR > p.title LIKE '%$keyword%') > UNION > (SELECT p.page_id, p.page_url AS url, p.title AS > title, > p.descrip AS descrip > FROM url_pages u > WHERE u.page_url LIKE '%$keyword%')"); > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]