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
";

 

 

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

posted @ 2019-01-02 14:09  Gupq  阅读(279)  评论(0编辑  收藏  举报