我有两个sql语句:
select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and t.city_name=planadmin.city_name ))
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and planadmin.watersupply_population > t.F7 ))
then 1 else 0 end as keyid1 FROM t where t.F7 is not null order by t.city_name
怎么把他合成一个语句??
select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and t.city_name=planadmin.city_name ))
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and planadmin.watersupply_population > t.F7 ))
then 1 else 0 end as keyid1 FROM t where t.F7 is not null order by t.city_name
怎么把他合成一个语句??
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name
union
select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and planadmin.watersupply_population > t.F7 ))
then 1 else 0 end as keyid1 FROM t where t.F7 is not null order by t.city_name
(t.city_name=planadmin.city_name or planadmin.watersupply_population > t.F7)))
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name
union
select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and planadmin.watersupply_population > t.F7 ))
then 1 else 0 end as keyid1 FROM t where t.F7 is not null order by t.city_name
then 1 else 0 end as keyid FROM t where t.F7 is not null order by t.city_name
union
select t.*,case when (EXISTS(SELECT * FROM planadmin where planadmin.file_ not in ('xx') and planadmin.watersupply_population > t.F7 ))
then 1 else 0 end as keyid1 FROM t where t.F7 is not null order by t.city_name
同一张表能这么用吗??
这样用会报错:
Incorrect syntax near the keyword 'union'.