您的位置:首页 > 产品设计 > UI/UE

MySQL_Table_Join_Query

2016-05-04 00:00 211 查看
摘要: Internal connection -- No connection -- Where = -- Abbreviation -- External connection -- Multi condition (and)

1. Internal connection

i. No connection

select * from t_book, t_bookType;




ii. Where =

select bookName, author, bookTypeName  from t_book, t_bookType where t_book.bookTypeId = t_bookType.id;




iii. Abbreviation

select tb.bookName, tb.author, tbt.bookTypeName  from t_book tb, t_bookType tbt where tb.bookTypeId = tbt.id;




2. External connection

Be careful: left join --> all information of first table

right join --> all information of second table

select * from t_book tb left join t_bookType tbt on tb.bookTypeId = tbt.id;
select * from t_book tb right join t_bookType tbt on tb.bookTypeId = tbt.id;




3. Multi condition --> and

select tb.bookName, tb.author, tb.price, tbt.bookTypeName  from t_book tb, t_bookType tbt where tb.bookTypeId = tbt.id and tb.price>70;


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: