Created
April 6, 2018 07:51
-
-
Save sajadshafizadeh/1a492c0d6a1ae6afbca8bdd1ca10d659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT e.id, e.table_code, | |
( SELECT id FROM events | |
WHERE author_id = 32 | |
GROUP BY type, post_id, table_code, comment_id, context | |
ORDER BY date_time DESC | |
LIMIT 15 ) ids | |
FROM events e | |
WHERE e.author_id = 32 AND e.id >= MIN(ids) | |
ORDER BY date_time DESC |
#1054 - Unknown column 'e.author_id' in 'having clause'
Are you sure there is a column with the name author_id
?
Yes I am.
OK, got it try this:
SELECT e.id, e.table_code,
( SELECT id FROM events
WHERE author_id = 32
GROUP BY type, post_id, table_code, comment_id, context
ORDER BY date_time DESC
LIMIT 15 ) ids
FROM events e
WHERE e.author_id = 32
ORDER BY date_time DESC
HAVING e.id >= MIN(ids)
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'HAVING e.id >= MIN(ids) LIMIT 0, 25' at line 12
Oh, sorry. Just move the last line before the ORDER BY
Now try this:
SELECT e.id, e.table_code,
FROM events e
WHERE e.author_id = 32
AND e.id >= (SELECT MIN(id) FROM events
WHERE author_id = 32
GROUP BY type, post_id, table_code, comment_id, context
ORDER BY date_time DESC
LIMIT 1)
ORDER BY date_time DESC
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM events e
WHERE e.author_id = 32
AND e.id >= (SELECT MIN(id) FROM events ' at line 3
I don't know what to do anymore. :(
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: