Reputation: 949
I am trying this code:
SELECT COUNT (oferta_id_oferta)
FROM `oferta_has_tags`
WHERE oferta_id_oferta =
(SELECT id_oferta FROM oferta
WHERE oferta = "designer")
I receive error: 1630 - FUNCTION mydb.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
If I remove the COUNT
word, I get two results.
What is the problem?
Upvotes: 29
Views: 39310
Reputation: 7336
Try removing the space between COUNT and the parentheses:
SELECT COUNT(oferta_id_oferta)
FROM `oferta_has_tags`
WHERE oferta_id_oferta =
(SELECT id_oferta FROM oferta
WHERE oferta = "designer")
Also, you can probably get rid of your subquery by joining:
SELECT COUNT(oferta_id_oferta)
FROM `oferta_has_tags`, `oferta`
WHERE
oferta_has_tags.oferta_id_oferta = oferta.id_oferta
AND oferta.oferta = "designer"
Upvotes: 8
Reputation: 15242
Don't put a space
SELECT COUNT(oferta_id_oferta)
FROM `oferta_has_tags`
WHERE oferta_id_oferta =
(SELECT id_oferta FROM oferta
WHERE oferta = "designer")
Upvotes: 87