Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot



#1: In general, cheaper to INNER JOIN or two separate queries

Posted on 2011-10-04 00:24:12 by Dotan Cohen

I need two fields from two different tables. I could either run two
queries, or a single INNER JOIN query:

$r1=mysql_query("SELECT fruit FROM fruits WHERE userid = 1");
$r2=mysql_query("SELECT beer FROM beers WHERE userid = 1");
$r=mysql_query("SELECT fruits.fruit, FROM fruits INNER JOIN
beers ON fruits.userid = beers.userid WHERE beers.userid = 1");

In general, which is preferable? I don't have access to the production
machine to benchmark at the moment, but which is best practice?

Dotan Cohen

MySQL General Mailing List
For list archives:
To unsubscribe:

Report this message