#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Query crossing multiple table


    Hi all hope someone can help with this.

    I have the following query

    select cscommprofilesetid,count(*) cscommprofilesetid from cshandle where cshandletypeid=57 group by cscommprofilesetid

    which outputs this

    cscommprofilesetid | cscommprofilesetid
    --------------------+--------------------
    403 | 1
    402 | 2
    404 | 1

    However I need cscommprofilesetid to be replaced with a user ID, I can do this with this statment.

    select loginname from csuser where csuser.id IN (select csuserid from cscommprofileset where cscommprofileset.id = '402')

    but no matter what I try I cannot get this to work. The closest I got is this

    select loginname,cscommprofilesetid from csuser,cshandle
    > where cshandletypeid=57 AND csuser.id IN (select csuserid from cscommprofileset) group by cscommprofilesetid,loginname;"

    but this just outputs every row with a count thats not what I wanted.

    Can anyone help?

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2010
    Posts
    15
    Rep Power
    0
    Hi,

    You can try this
    select (select csuserid from cscommprofileset where id=cscommprofilesetid) as csuserid,count(*) cscommprofilesetid from cshandle where cshandletypeid=57 group by 1;


IMN logo majestic logo threadwatch logo seochat tools logo