On Sun, April 24, 2005 3:51 pm, Schalk Neethling said:
> Hope someone can give me some pointers here. I have six tables in the
> database and I need to JOIN them on a row that appears in all of the
> tables. How do I do this? I have so far done the normal 'cross-join'
> saying SELECT * FROM table1, table2, table3, table4, table5, table6
> WHERE something = something;

SELECT *
FROM table1, table2, table3, table4, table5, table6
WHERE table1.something = table2.something
  AND table2.something = table3.something
  AND table3.something = table4.something
  AND table4.something = table5.something
  AND table5.something = table6.something

Make sure 'something' has an index on each table.

Also, don't use SELECT * unless you really NEED every column, and always
will, no matter how the schema changes.

If there's any chance at any time in the future that you won't need EVERY
column, then specify each and every column you need individually:

SELECT table1.something, table1.whatever, table2.something_else

-- 
Like Music?
http://l-i-e.com/artists.htm


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to