mysql内部_使用mysql中的内部加入
我有三張桌子
地點
ID | NAME | TYPE |
1 | add1 | stat |
2 | add2 | coun |
3 | add3 | coun |
4 | add4 | coun |
5 | add5 | stat |
學校
ID | NAME
1 | sch1
2 | sch2
3 |sch3
school_locations
ID |LOCATIONS_ID |SCHOOL_ID
1 | 1 |1
2 | 2 |2
3 | 3 |3
這里的表位置包含應用程序的所有位置。學校的地址由ID調用。
當我使用查詢
select locations.name from locations where type="coun";
它顯示類型為“coun”的名稱
但是我想顯示locations.name只有school_locations有type =“coun”
我嘗試了以下查詢,但沒有一個似乎是工作
select locations.name
from locations
where type="coun"
inner join school_locations
on locations.id=school_locations.location_id
inner join schools
on school_locations.school.id=schools.id;
和
select locations.name
from locations
inner join school_locations
on locations.id=school_locations.location_id
inner join schools
on school_locations.school.id=schools.id where type="coun";
是否可以在查詢中使用多個內聯,還是有其他方式?
總結
以上是生活随笔為你收集整理的mysql内部_使用mysql中的内部加入的全部內容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 什么是家乡的“四月八庙会”?
 - 下一篇: 清蒸鱼家常做法?