select*fromaunionallselect*frombunionallselect*fromc上边的做法是如果a,b,c里有相同项的话会一并显示出来select*fromaunionselect*frombunionselect*fromc这样的做法是如果三张表有完全相同的项,会只显示一条。
- 情感问答
- 答案列表
查询多个表:表是整个数据系统的[朗读]
这要看你的查询方式,你是准备把所有结果一起显示就用unionall如果不一起显示就写10个select的语句。
一使用select子句进行多表查询select字段名from表1,表2…where表1.字段=表2.字段and其它查询条件selecta.id,a.name,a.address,a.date,b.math,b.english,b.chinese。
如果两个表的结构一样,可以这样查:select*fromtableaunionselect*fromtableb。
sql中多表查询可以使用链接查询1、unionunion[all]all:表示将查询的所有结果都合并到结果集中,若不加all会将重复的行只保留一行--示例:select*fromaunionselect。