gollem
asked on
#1054 - Unknown column ... in 'having clause'
Hi,
Can somebody see what's the problem with following SQL-statement. I've tested in Access and it worked but in MySQL it fails.
SELECT re.*
FROM recipient re,recipient2targetgroup r2t
WHERE re.recipient_id=r2t.recipi ent_id and r2t.targetgroup_id=26
and re.recipient_id in(
SELECT t.recipient_id
FROM recipient r, recipient2targetgroup t
GROUP BY r.recipient_id, t.recipient_id
having r.recipient_id = t.recipient_id and count(t.recipient_id) > 1 )
I get following error:
#1054 - Unknown column 'r.recipient_id' in 'having clause'
Thanks for the assistance.
Gollem
Can somebody see what's the problem with following SQL-statement. I've tested in Access and it worked but in MySQL it fails.
SELECT re.*
FROM recipient re,recipient2targetgroup r2t
WHERE re.recipient_id=r2t.recipi
and re.recipient_id in(
SELECT t.recipient_id
FROM recipient r, recipient2targetgroup t
GROUP BY r.recipient_id, t.recipient_id
having r.recipient_id = t.recipient_id and count(t.recipient_id) > 1 )
I get following error:
#1054 - Unknown column 'r.recipient_id' in 'having clause'
Thanks for the assistance.
Gollem
ASKER
Hi,
if I do this, won't I get the same error but than for this field?
=>t.recipient_id
...
and re.recipient_id in(
SELECT r.recipient_id
FROM recipient r, recipient2targetgroup t
GROUP BY r.recipient_id, t.recipient_id
having r.recipient_id = t.recipient_id and count(t.recipient_id) > 1 )
Thanks again for the help.
Gollem
if I do this, won't I get the same error but than for this field?
=>t.recipient_id
...
and re.recipient_id in(
SELECT r.recipient_id
FROM recipient r, recipient2targetgroup t
GROUP BY r.recipient_id, t.recipient_id
having r.recipient_id = t.recipient_id and count(t.recipient_id) > 1 )
Thanks again for the help.
Gollem
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the help it works now. :)
To fix it, simply change your subquery to
SELECT r.recipient_id...