欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mysql left join 博客分类: DB-Mysql Mysql左连接 

程序员文章站 2024-03-16 12:03:16
...

Mysql left join:

 case 1:

select ifnull(tv2.venueName,tv1.venueName) as venueName,ts.ticketSubtypeName, a.* 
from t_ticket a left join t_ticket_subtype ts on a.ticketSubtypeId=ts.id left join t_venue tv2 on ts.venueId=tv2.id left join t_venue tv1 on a.venueId=tv1.id 
where  a.id=1;

 

case 2:

select tv.venueName,ta1.name createUser,ta2.name updateUser, FROM_UNIXTIME(t.createTime/1000) createTimeStr,t.* 
from 
t_ticket_subtype t left join admin_user ta1 on t.createUser=ta1.id 
left join admin_user ta2 on t.updateUser=ta2.id 
left join t_venue tv on t.venueId=tv.id
where t.id=1
order by id desc;

 

 

 

 

 

相关标签: Mysql 左连接