I have 2 working MYSQL statements, that I would like to merge into 1 query:
from mysql select statement with unique and maximum selects? I have:
SELECT field_a, max(dup_number) as dup FROM table1 GROUP BY field_a
my second query is:
where contacts=0 ORDER BY date LIMIT 3
so a group of records would look schematically like:
ID FIELD A DUP_NUMBER CONTACTS
1 text1 0 1 --
2 text2 0 3 --
3 text2 1 3 --
4 text2 2 3 --
5 text3 0 2 --
I've come up with:
SELECT *
FROM `table1 `
where max(`DUP_NUMBER `) as dup and `CONTACTS`=1
GROUP BY `FIELD_A`
ORDER BY date
LIMIT 3
When I test in PHPMyAdmin I get
#1064 - You have an error in your SQL syntax.
Can anyone show me how to rewrite this correctly?