一、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
![](https://www.linwute.com/wp-content/uploads/2022/08/image-9.png)
二、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
![](https://www.linwute.com/wp-content/uploads/2022/09/image-2.png)
1,187 Views