Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

www.xxxcon, www xxxcon, board.issociate.de, registrieren fehler dll server 0x8002801c, far2 vs near2 raid10, access abfragen aus linux, "Can't send mail: sendmail process failed with error code 69", superduper 2.1.4 serial, www.xxx.con, 192.168.1.41:8000

Links

XODOX
Impressum

#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");
--or--
$r=mysql_query("SELECT fruits.fruit, beers.beer 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?
Thanks!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Report this message