Chris Sansom wrote:
At 16:37 +0200 11/4/06, Barry wrote:

select [what you want]
 from t1
 LEFT JOIN t2 ON t2.id = t1.id
 LEFT JOIN t3 ON t3.id = t1.id
 LEFT JOIN t4 ON t4.id = t1.id
 LEFT JOIN t5 ON t5.id = t1.id
 LEFT JOIN t6 ON t6.id = t1.id
 where
    t2.text like '%search_term%' OR t3.text like '%search_term%' OR
    t4.text like '%search_term%' OR t5.text like '%search_term%' OR
    t6.text like '%search_term%' ORDER BY t1.id ASC;


That's the one! Thanks so much, Barry - looks like I've a lot still to learn. :-) I had a sneaking feeling the answer might lie in left join, but nowhere in my otherwise excellent MySQL book (it's the one for version 3 by Paul DuBois), nor in any online docs I could find, could I see how to combine more than one.

This works like a charm anyway - thanks again. Not only that, but I /think/ I understand it. ;-)

Haha, no problem :D

Once you get a hang on JOINs you will love it =)

Just remember:

everytime you do something like this: WHERE table1.id = table2.id
You will be safer and faster to use JOINs because that's what ON is for:
LEFT JOIN table2 ON table1.id = table2.id

LEFT join puts the WHOLE table2 to the right of the LEFT JOINED table1.

example:
(Hi, i'm table 1 with all my content) LEFT JOIN (Hi, i'm table 2 with all my content)

if you use Where:
(Hi, i'm table 1 with all my content) WHERE t2.id = t1.id (Hi, i'm table 2 but only giving you the content you wanted to see with your WHERE clause, i keep the rest for myself!!)

Greets
        Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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

Reply via email to