mysql两条sql如何合并

2024-10-27 04:47:23

1、我用Toad做演示,我先新建两张table,create table #AA(ID int,name nvarchar(10),age int)create table #BB(ID int,name nvarchar(10),age int )

mysql两条sql如何合并

3、现在要求AB两个班找出年龄等于10岁的同学,最直接的方法就是:select * from #AA where age=10select * from #BB where age=10但是这样会产生两个结果集,结果不直观!

mysql两条sql如何合并

5、还有一种不用union的做法,sql语句这样写:select a.*,b.* from #AA a inner join #BB b on a.age=b.agewhere a.age=10 and b.age=10这种写法就是要找出主键外键的关联关系,但是结果就不好直观来阅读,因为结果集是混乱的

mysql两条sql如何合并
猜你喜欢