ThinkPHP/---union

Posted Gupq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ThinkPHP/---union相关的知识,希望对你有一定的参考价值。

$sql = "
(select id,‘1‘as type ,content,photo,issuetime as t from experience where userid = {$userid})
UNION ALL
(select id,‘2‘as type, name as content,id as photo,ts as t from importantday where userid = {$userid})
UNION ALL
(select id,‘3‘as type,title as content,id as photo,ts as t from inspiration where userid = {$userid})
UNION ALL
(select id,‘4‘as type,title as content,photo,issuetime as t from sendword where userid = {$userid})
ORDER BY t desc
";

 

 

字段数量与字段名 必须保持一致

以上是关于ThinkPHP/---union的主要内容,如果未能解决你的问题,请参考以下文章