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?
COUNT(*) returns the number of rows in a specified table, and it preserves duplicate rows. It counts each row separately. This includes rows that contain null values.
The simple answer is no – there is no difference at all. The COUNT(*) function counts the total rows in the table, including the NULL values.
The result is a BIGINT value. It is an aggregate function, and so can be used with the GROUP BY clause. COUNT(*) counts the total number of rows in a table. COUNT() returns 0 if there were no matching rows.
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")
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"
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