View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 11:32 AM
FFMG
 
Posts: n/a
Default Complex JOIN vs multiple selects


Hi,

if I have 3 or more table all 'linked' by an ID.
Is it better to have one query or 3 or more SELECT?

For example

// -- EXAMPLE A
SELECT something FROM t1 LEFT JOIN t2 ON t2.id=t1.id LEFT JOIN t3 ON
t3.id=t1.id WHERE t1.id=xx

// -- EXAMPLE B
SELECT something FROM t1 WHERE t1.id=xx
...
SELECT something FROM t2 WHERE t2.id = $t1id
SELECT something FROM t3 WHERE t3.id = $t1id

From the DB point of view does it really matter?
Doesn't MySQL break EXAMPLE A into EXAMPLE B?

And if I was to put it all into a stored procedure, should I keep the
LEFT JOIN or should I break it down into multiple selects?

I guess what I am asking is, does MySQL really care how I present it as
it will be hitting all 3 tables the same way in the end.

Thanks

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=24324

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

Reply With Quote