from table1, table2 where table1.col=table2.col
慎用第一种,对于数据量大的来说,是先查询所有的表在查询后面的条件,相当于n*n
left join 会从左表 (table_name1) 那里返回所有的行,即使在右表 (table_name2) 中没有匹配的行。
左连接,
from table1 where table1.uid in (select … from table2)
在过去ssm系统中常使用改语句
实践中来看,左连接使用最多,可以优先考虑用左连接,并且左连接的查询效率更高
select brand_name, logo_url, category_tags_l2_name, join_total_cost from join_brand_hot h left join join_brand b on h.brand_code = b.brand_code where h.status = 1 <if test="today != null" > and (show_end_time is null or show_end_time >= #{today}) </if> order by sort desc, click_count desc