This is a discussion on count problem within the MySQL forums, part of the Database Server Software category; --> I'm working with the followin query, which works pretty well and retrieves 5 records: SELECT actores.id_actor_actores, peliculasactores.fk_id_actor_pelact, dvds.id_dvd_dvds, dvds.titulo_dvds ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm working with the followin query, which works pretty well and retrieves 5 records: SELECT actores.id_actor_actores, peliculasactores.fk_id_actor_pelact, dvds.id_dvd_dvds, dvds.titulo_dvds FROM actores INNER JOIN peliculasactores ON actores.id_actor_actores=peliculasactores.fk_id_ac tor_pelact INNER JOIN dvds ON peliculasactores.fk_id_pelicula_pelact=dvds.id_dvd _dvds WHERE actores.id_actor_actores=1001 ORDER BY dvds.fecha_ingreso_dvds DESC Now, I need to be able to previously count the result set, but i'm having trouble with "count" function SELECT count(*) FROM actores INNER JOIN peliculasactores ON actores.id_actor_actores=peliculasactores.fk_id_ac tor_pelact INNER JOIN dvds ON peliculasactores.fk_id_pelicula_pelact=dvds.id_dvd _dvds WHERE actores.id_actor_actores=1001 ORDER BY dvds.fecha_ingreso_dvds DESC Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT count (*) It seems that the problem has to do with the INNER JOIN, beacause i've used count(*) before (without inner joins) and it worked. Can anyone give me a hint? regards |
| ||||
| julian_m wrote: > I'm working with the followin query, which works pretty well and > retrieves 5 records: > > SELECT actores.id_actor_actores, peliculasactores.fk_id_actor_pelact, > dvds.id_dvd_dvds, dvds.titulo_dvds > FROM actores > INNER JOIN peliculasactores ON > actores.id_actor_actores=peliculasactores.fk_id_ac tor_pelact > INNER JOIN dvds ON > peliculasactores.fk_id_pelicula_pelact=dvds.id_dvd _dvds > WHERE actores.id_actor_actores=1001 > ORDER BY dvds.fecha_ingreso_dvds DESC > > Now, I need to be able to previously count the result set, but i'm > having trouble with "count" function > > SELECT count(*) > FROM actores > INNER JOIN peliculasactores ON > actores.id_actor_actores=peliculasactores.fk_id_ac tor_pelact > INNER JOIN dvds ON > peliculasactores.fk_id_pelicula_pelact=dvds.id_dvd _dvds > WHERE actores.id_actor_actores=1001 > ORDER BY dvds.fecha_ingreso_dvds DESC > > Error Code : 1064 > You have an error in your SQL syntax; check the manual that corresponds > to your MySQL server version for the right syntax to use near 'SELECT > count (*) > > It seems that the problem has to do with the INNER JOIN, beacause i've > used count(*) before (without inner joins) and it worked. Can anyone > give me a hint? > > regards > According to the error message, you used "count (*)" instead of "count(*)" (notice the space). ciao gmax -- _ _ _ _ (_|| | |(_|>< _| http://gmax.oltrelinux.com |