Home  >  Article  >  Database  >  三表查询 MYSQL句子_MySQL

三表查询 MYSQL句子_MySQL

WBOY
WBOYOriginal
2016-06-01 13:06:36986browse
SELECT cp.cname, cp.cprice, dc.dcsum, cp.cprice*dc.dcsum as fensu,sj.sjname FROMcp,dc,sj WHERE cp.cno=dc.dcno AND cp.sjno = sj.sjnohittlle原来这么简单。。。我想复杂了。。注意:三个表a,b,c 查询的时候要注意他们之间要有牵制,比如 a.s=b.s and a.s=c.s 这样,否则会有重复的东西出来,就算加了distinct 只会减少重复,而不能避免重复。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn