I am using sqlite to fetch data from chat table but it keeps giving me error at UNION.
Here is my query:
SELECT a.id, a.timeDate, a.message, fromUser, toUser FROM ((SELECT id, message, fromUser, toUser, toUser AS uid, timeDate FROM chat WHERE fromUser = ?) UNION (SELECT id, message, fromUser, toUser, fromUser AS uid, timeDate FROM chat WHERE toUser = ? )) AS a GROUP BY a.uid ORDER BY a.id DESC , a.uid DESC
I tried with brackets before UNION and without bracket like
(query1) UNION (query2) and (query1 UNION query2) but still that’ not working.
This query is working fine in mysql with same structured table.
How to solve this problem?