hi,

Thanks to Christoph. I found a solution but wondering is there any
better way to get rid of this long SQL query. Its fine for me to have a
multistep procedure

$query = <<< SQL
select
  Users.id as user_id,
  Users.name as user_name,
  Singers.id as singer_id,
  Singers.name as singer_name,
  count(Songs.id) as songs_in_lib
from
  Users left join Songs_users on Users.id = Songs_users.user_id,
  Singers left join Singers_songs on Singers.id =
Singers_songs.singer_id,
  Songs
where
  Songs.id = Singers_songs.song_id and
  Songs_users.song_id = Songs.id and
  Users.id = 1
group by
  Users.id,
  Users.name,
  Singers.id,
  Singers.name
order by
  Users.name,
  Singers.name
SQL;


     $data = $this->User->query($query);
     $this->set('data',$data); 

Regards,
Ritesh


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to