2011-10-20 15 views
17

estoy tratando este código:recuento de SQL - no trabajar

SELECT COUNT (oferta_id_oferta) 
FROM `oferta_has_tags` 
WHERE oferta_id_oferta = 
(SELECT id_oferta FROM oferta 
WHERE oferta = "designer") 

recibo error: 1630 - FUNCTION mydb.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual

Si quito la palabra COUNT, consigo dos resultados.

¿Cuál es el problema?

Respuesta

49

No ponga un espacio

SELECT COUNT(oferta_id_oferta) 
FROM `oferta_has_tags` 
WHERE oferta_id_oferta = 
(SELECT id_oferta FROM oferta 
WHERE oferta = "designer") 
+4

dios, un espacio. gracias :) – user947462

+0

De nada: D – msarchet

+0

Solución perfecta :-) – Henry8

6

intente eliminar el espacio entre contar y los paréntesis:

SELECT COUNT(oferta_id_oferta) 
FROM `oferta_has_tags` 
WHERE oferta_id_oferta = 
(SELECT id_oferta FROM oferta 
WHERE oferta = "designer") 

Además, es probable que pueda deshacerse de su sub consulta uniendo:

SELECT COUNT(oferta_id_oferta) 
FROM `oferta_has_tags`, `oferta` 
WHERE 
    oferta_has_tags.oferta_id_oferta = oferta.id_oferta 
    AND oferta.oferta = "designer"