MySQL多行查询 并自定义值返回

一、MySQL多行查询 并自定义值返回

select id,intShow,@a:='a' from a_data where `intShow` = 2
union all
select id,intShow,@a:='b' from b_data where `intShow` = 2
union all
select id,intShow,@a:='c' from c_data where `intShow` = 2
order by id desc

二、Mysql 自定义值返回字段( 格式:’值’ AS 字段)

SELECT id,intShow,idSchool,'life' AS block,expireDate,date FROM `life` UNION ALL 
SELECT id,intShow,idSchool,'like' AS block,expireDate,date FROM `like` UNION ALL 
SELECT id,intShow,idSchool,'info' AS block,expireDate,date FROM `info` UNION ALL 
SELECT id,intShow,idSchool,'my' AS block,expireDate,date FROM `my` ORDER BY id DESC
90 Views
分享你的喜爱
linwute
linwute

我要像梦一样自由,像大地一样宽容;
在艰辛放逐的路上,点亮生命的光芒;
我要像梦一样自由,像天空一样坚强;
在曲折蜿蜒的路上,体验生命的意义;

留下评论

您的电子邮箱地址不会被公开。