At 12:02 +0900 8/29/02, suresh wrote: >Hi >I changed from mysql 3.23.49 -nt to 4.0.2 max to make use of union > >But one problem when trying to join tables is that UNION works >only for SELECT queries with same number of coulmns.
Well, that's how UNION works. > Is there any way to join 3 or more tables having different columns >using UNION? Sure, you can use different columns. But you have to have the same *number* of columns. > I am writing my query during the runtime. Since the user can select >any number of fileds from a particular table and also I am using >LEFT JOIN, I can't make all the tables having same number of fields. Sure you can. Add fake columns that select some constant value, like an empty string, 0, or NULL. Pad the "short" tables with enough of these so that you select the same number of columns from each. If you don't have any way to tell how many columns are selected, then you're stuck. But I find it hard to conceive of such a situation. > >Thanks for any help --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php