I\'ve 2 tables:
first table users
:
+-------------------------+---------+------+-----+---------+-------+
| Field | Type
Have you tried switching not exists
to left join
?
SELECT DISTINCT *
FROM profiles t1
LEFT JOIN
proposal t2
ON t1.id = t2.to_id
WHERE t1.first_name IS NOT NULL AND
t2.to_id IS NULL
ORDER BY RAND()
LIMIT 0 , 1
This will return you all rows of profiles
, and to those that are not matched
by a row in proposal it will assign NULL
values, on which you can filter.
The result should be the same, but the performance may be better.