"Chris Boget" <[EMAIL PROTECTED]> wrote: > Can you UNION 2 queries and use the result to JOIN with another table? > > (SELECT tableA.name, tableC.company FROM tableA) > UNION > (SELECT tableB.name FROM tableB) > LEFT JOIN tableC ON tableA.name = tableC.name; > > This doesn't work. But I don't know if it isn't working because I have the > wrong syntax or if it's simply not possible with SQL/MySQL.
First of all SELECT statement in the UNION have different numbers of column. From v4.1 you can rewrite your query as: SELECT .. FROM (SELECT .. FROM tableA UNION SELECT .. FROM tableB) AS result_table LEFT JOIN tableC ON .. -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]