有这样一个数据库表格字段1 字段2 字段3 字段4 字段5 字段6
1 2 a a1 b b1
2 3 c c1 a a2想得到‘字段3’或者‘字段5’=a的记录
字段4和字段3,字段6和字段5是相关的,一起查出来。要查询的结果为
字段1 字段2 字段3 字段4
1 2 a a1
2 3 a a2请教用sql怎么做查询?
1 2 a a1 b b1
2 3 c c1 a a2想得到‘字段3’或者‘字段5’=a的记录
字段4和字段3,字段6和字段5是相关的,一起查出来。要查询的结果为
字段1 字段2 字段3 字段4
1 2 a a1
2 3 a a2请教用sql怎么做查询?
union
select 字段1 字段2 字段5 字段6 from table where 字段5='a'
union
select 字段1, 字段2, [字段5] as 字段3, [字段6] as 字段4 from 表 where 字段5='a'