2
I would like to know how I create a limit for a query that uses UNION
in Mysql, in my case I want to define the LIMIT 5
for the following query:
$friends_a = mysql_query("(SELECT * FROM users WHERE id!='$user_q[id]' AND
id='$friends_1_q[user_one_id]') UNION ALL (SELECT * FROM users WHERE
id!='$user_q[id]' AND id='$friends_1_q[user_two_id]')");
I’ve tried with several codes I found on the internet and I can’t, which I should do?
No, it didn’t work, it returned the empty query. What refers to 'table'?
– Hélio Júnior
table is the data resulting from UNION ALL, ie Query1 UNION ALL query2 = table, so I do a SELECT to return all table data by placing the LIMIT 5.
– Alessandro Barros