inner join
Posted bellwether
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了inner join相关的知识,希望对你有一定的参考价值。
数据库中多表关联查询。
select c.CARCARDNUMBER as 车牌号码,‘蓝牌‘ as 车牌颜色,‘小型轿车‘ as 车辆类型,‘出租客运‘ as 使用性质,c.CARBRAND as 车辆品牌,c.CARVERSION as 车辆型号,c.ISDOUBLEFULE as 是否双燃料车,
fu.name as 燃料种类,c.REGISTERDATE as 注册日期,a.checktime as 最后一次检查时间,d.stationname as 检测站,m.name as 检测方法
from BAS_CARINFO c
inner join (select mas.* from INS_CHECKRESULTMAIN mas inner join (select carpkid,max(checktime) as checktime from INS_CHECKRESULTMAIN group by carpkid) ma on mas.carpkid=ma.carpkid and mas.checktime=ma.checktime) a on a.carpkid=c.pkid
INNER JOIN BAS_CHECKSTATION d on d.PKID=a.stationpkid
left join COD_CARDCOLOR e on e.code=c.carcardcolor
left join COD_CARMODE f on f.code=c.CARMODE
left join COD_CHECKMETHOD m on m.code=a.checkmethod
left join cod_FUELTYPE fu on fu.code=c.fueltype
where "TO_CHAR"(a.checktime,‘yyyy-mm-dd‘)>=‘2019-05-01‘ and "TO_CHAR"(a.checktime,‘yyyy-mm-dd‘)<=‘2019-11-01‘ and c.USEDQUALITY=‘33‘ and c.CARMODECODE=‘K33‘
order by STATIONNAME,checktime
select t.name 姓名,t.password from table t ; t表示替换字符,可以用t直接点出。姓名表示 索引头用姓名替代name. as这个可有可无
inner join left join 添加关联
to_date(‘2020-02-02‘,‘yyyy-mm-dd‘) 查询的时间表示方法
on 用来关联表中的字段对应另一张表中的字段
以上是关于inner join的主要内容,如果未能解决你的问题,请参考以下文章
简单 left joininner joingroup byhaving in
sql之left joinright joininner join的区别
left joinright joininner join的区别
mysql之left joinright joininner join的区别