Here is my original query...
SELECT `id`
FROM `properties`
LIMIT 10, 20
The LIMIT
condition is for pagination.
Now, I have to get all like before, but I need to get only a third of rows where a condition is present.
I came up with this, just throwing LIMIT 30
in before I figured out how to do (total rows matched / 3) * 2.
SELECT `id`
FROM `properties`
WHERE `id` NOT IN (SELECT `id`
FROM `properties`
WHERE `vendor` = "abc"
ORDER BY RAND()
LIMIT 30)
LIMIT 10, 20
MySQL said...
1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
I guess I can't use LIMIT
in a subquery.
So this is a multi question but all related...
LIMIT
in subquery?Sorry I'm late, this worked for me:
SELECT p.id
FROM properties p
LEFT JOIN (SELECT t.id
FROM PROPERTIES t
WHERE t.vendor = 'abc'
ORDER BY RAND()
LIMIT 30) x ON x.id = p.id
WHERE x.id IS NULL
LIMIT 10, 20
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With