Sometimes in the database query will be used when the union query, but the query will find that two limit only one is valid, the following query
SELECT * FROM table where status = 0 limit* from table where status = 1 limit 30
The actual query effect of such a statement is as follows:
(SELECT * from table where status = 0 limit* from table where status = 1) limit 20
If you want limit to work, you have to put the limit in parentheses.
The Notorm in Phalapi is as follows:
Public functiongetsogouguojilist () {$result=Array(); $query= DI ()->notorm->table->select (' Id,title,content ') ->where (' status =? ', 0)->order (' id desc ') ->limit (10); $query 2= DI ()->notorm->table->select (' Id,title,content ') ->where (' status =? ', 0)->order (' id desc ') ->limit (20); foreach($query->union ($query 2) as $row) { $result[] =$row; } return $result; }
Note: If there is a wrong place also please advise.
PHALAPI Union and UNION all in use