user 表
id usernamecard 表
id, cardusername, cardpricerent 表
id userid cardid endtimeselect * from card C where id in (select cardid from rent where userid = (select id from user where username="lihan519")) 这样能把card表所有的东西查询出来
关键是怎么样把RENT表里的endtime 和这个查询出来的行成 并列连接!
如下所示(要求实现如下)id cardname cardprice endtime
1 12 33 2009-12-12
2 34 32 2009-12-12
3 23 23 2009-12-12
id usernamecard 表
id, cardusername, cardpricerent 表
id userid cardid endtimeselect * from card C where id in (select cardid from rent where userid = (select id from user where username="lihan519")) 这样能把card表所有的东西查询出来
关键是怎么样把RENT表里的endtime 和这个查询出来的行成 并列连接!
如下所示(要求实现如下)id cardname cardprice endtime
1 12 33 2009-12-12
2 34 32 2009-12-12
3 23 23 2009-12-12
inner join rent on c.id=rent.cardid
inner join user on rent.userid=user.id
where user.username="lihan519"
from (card c left join rent on c.id=rent.cardid )
left join user on rent.userid=user.id
where user.username='lihan519'