---table1指的是第一張表,table2指的是第二張表,table3指的是第三張表,
清河網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),清河網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為清河成百上千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的清河做網(wǎng)站的公司定做!
select??a.uid,a.uname,a.upsw,a.urealname,a.utel,a.remark,b.rname,b.rremark,c.deptname,c.deptremark?from?table1?a,table2?b,?table3?c?where?a.sems_role_rid=b.rid?and?a.udeptid=c.deptid
有兩種方式: 關(guān)鍵字where 或嵌入在inner 或left 中:
下面定義3個(gè)表A,B,C,字段分別為A:a,b;B:b,c;C:c,d
正常where 使用語(yǔ)句如下:
select A.a,B.b,C.c from A
inner join B on A.b=B.b
inner join C on C.c=B.c
where A.a=10 or B.b=10 or C.c=10
下面的SQL 嵌入到inner 中的使用方式:
select A.a,B.b,C.c from A
inner join B on A.b=B.b and B.b=10
inner join C on C.c=B.c and C.c=10
select * from student as s,guanliyuan as g,teacher as t
where s.ids = g.ids and s.ids = t.ids
條件可以根據(jù)你的需要來查詢。
SELECT id FROM table1 where a='12'
union all
SELECT id FROM table2 where a='12'
union all
SELECT id FROM table3 where a='12';
SELECT aaa.id, REPLACE(bbb.bcode, bbb.bcode, 'a') aa, REPLACE(ccc.ccode, ccc.ccode, 'b') bb, concat_ws( '', REPLACE(bbb.bcode, bbb.bcode, 'a'), REPLACE(ccc.ccode, ccc.ccode, 'b')) ab FROM a aaa left Join b bbb ON ( aaa.id = bbb.ida ) left Join c ccc ON ( aaa.id = ccc.idb ) ORDER BY aaa.id ASC
我專門建了跟你一模一樣的表,測(cè)試過了,出來的結(jié)果也跟你要的一模一樣。
你最想要的結(jié)果:
SELECT aaa.id, concat_ws( '', REPLACE(bbb.bcode, bbb.bcode, 'a'), REPLACE(ccc.ccode, ccc.ccode, 'b')) ab FROM a aaa left Join b bbb ON ( aaa.id = bbb.ida ) left Join c ccc ON ( aaa.id = ccc.idb ) ORDER BY aaa.id ASC
mysql數(shù)據(jù)庫(kù)?
select * from name a,user u,level l where l.id=u.level and n.pk.user.id=u.pk.user.id
當(dāng)前文章:mysql怎么查三個(gè)表,mysql三表查詢
文章分享:http://jinyejixie.com/article30/hsepso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁(yè)設(shè)計(jì)公司、外貿(mào)建站、定制網(wǎng)站、微信小程序、軟件開發(fā)、營(yíng)銷型網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)