SQL查询语句问题如何将多个相同结构的表,合并成一个大表再查询? 20
[effect]ideffect1effect21101102011011022121011024110110212310110232101102424101102421...
[effect]
id effect1 effect2
1 10110201 10110221
2 10110241 10110212
3 10110232 10110242
4 10110242 10110212
5 10110242 10110221
6 10110242 10110201
...
[item1]
ID _Name
10110201 青铜手套
10110202 黄铜手套
10110211 (地)青铜手套
10110212 (地)黄铜手套
[item2]
ID _Name
10110221 (水)青铜手套
10110222 (水)黄铜手套
10110231 (风)青铜手套
[item3]
ID _Name
10110232 (风)黄铜手套
10110241 (火)青铜手套
10110242 (火)黄铜手套
如上所示,3个表名分别维 effect item1 item2 item3 由于 item1~3的数据较大的关系,所以才拆分了3个表,
要求: 将 effect 表的 effect1 effect2 字段 当做查询条件, 查询出 item 三合一后的表的 name字段名
求语句..谢谢了 展开
id effect1 effect2
1 10110201 10110221
2 10110241 10110212
3 10110232 10110242
4 10110242 10110212
5 10110242 10110221
6 10110242 10110201
...
[item1]
ID _Name
10110201 青铜手套
10110202 黄铜手套
10110211 (地)青铜手套
10110212 (地)黄铜手套
[item2]
ID _Name
10110221 (水)青铜手套
10110222 (水)黄铜手套
10110231 (风)青铜手套
[item3]
ID _Name
10110232 (风)黄铜手套
10110241 (火)青铜手套
10110242 (火)黄铜手套
如上所示,3个表名分别维 effect item1 item2 item3 由于 item1~3的数据较大的关系,所以才拆分了3个表,
要求: 将 effect 表的 effect1 effect2 字段 当做查询条件, 查询出 item 三合一后的表的 name字段名
求语句..谢谢了 展开
1个回答
展开全部
select effect.effect1, a.name name1, effect.effect2, b.name name2
from effect, (select * from item1 union select * from item2 union select * from item3) as a ,(select * from item1 union select * from item2 union select * from item3) as b where effect.effect1 = a.id and effect.effect2 = b.id
from effect, (select * from item1 union select * from item2 union select * from item3) as a ,(select * from item1 union select * from item2 union select * from item3) as b where effect.effect1 = a.id and effect.effect2 = b.id
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询