Unix Technical Forum

count problem

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:13 AM
julian_m
 
Posts: n/a
Default count problem

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 07:13 AM
Giuseppe Maxia
 
Posts: n/a
Default Re: count problem

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:21 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com