1、两个表之间sql逻辑left join,right join,inner join,full join之间的区别:
感谢:https://www.cnblogs.com/lijingran/p/9001302.html
但是
SELECT p.LastName, p.FirstName, o.OrderNo
FROM Persons p
INNER JOIN Orders o
ON p.Id_P=o.Id_P and 1=1 --用and连接多个条件
ORDER BY p.LastName
和SELECT p.LastName, p.FirstName, o.OrderNo
FROM Persons p,Orders o
where p.Id_P=o.Id_P 的效果是一样的
2、A表中有个字段column_aa,B表中有个字段column_bb
如果需要查询出B表中字段column_bb like A表中column_aa字段的纪录,可以使用如下语句
select A.* from A left join B on column_aa like concat("%",column_bb,"%") ;
感谢:https://www.cnblogs.com/kingxiaozi/p/6393168.html
3、【Mysql】求两个表(查询结果)的差集
select id from usertable where id not in (select id from blog)
https://blog.csdn.net/yongh701/article/details/51689976
4、如何查询一个表中某个字段相同的数据,如下
select * from students group by teacher_id HAVING COUNT(teacher_id)>1;