PHP+Mysql 三表查询 【求解】

孙小涛 发布于 2014/06/13 14:32
阅读 838
收藏 0


php+mysql



加载中
0
上班杀人
上班杀人
select a.charact, b.categoryname, c.s1_name from tbl_orders_detail a join tbl_category b on a.categoryid = b.categoryid join tbl_server c on a.serverid = c.serverid where a.ord_id = 100
0
0
deadmau5
deadmau5
 不会写。
0
错II过
错II过
select charact,categoryname,sl_name from tbl_orders_detail,tbl_category,tbl_server  where tbl_orders_detail.serverid= tbl_server.serverid and tbl_orders_detail.categoryid=tbl_category.categoryid  and ?.odr_id=100      ord_id是哪个表的?
0
0xAB
0xAB
select a.charact,(select b.categoryname from tbl_category as b where b.categoryid=a.categoryid limit 1) as categoryname,(select c.sl_name from tbl_server as c where c.serverid=a.serverid limit 1) as sl_name from tbl_orders_detail as a where a.odr_id=100



0
工程师爸爸
工程师爸爸
SELECT detail.charact, cate.categoryname, serv.sl_name
FROM tbl_orders_detail AS detail 
LEFT JOIN tbl_category AS cate ON cate.categoryid = detail.categoryid
LEFT JOIN tbl_server   AS serv ON serv.serverid   = detail.serverid
WHERE detail.ord_id = 100
0
pcxsvl
pcxsvl

select a.charact, b.categoryname, c.sl_name

from tbl_orders_detail a,tbl_category b,tbl_category c

where b.categoryid = 510 and c.serverid = 88 and a.serverid =88 and a.categoryid = 510;

0
丙二军
丙二军
楼上两位大神的答案哪种效率会比较高呢?
0
B
Bryan0128

引用来自“丙二军”的评论

楼上两位大神的答案哪种效率会比较高呢?

join的效率高,left join是全表扫描

丙二军
丙二军
怒赞
返回顶部
顶部