一、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
1,330 Views