select count with table join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    select count with table join

    Hi, I wonder if anyone knows how to do this. I need to get info from another table and cannot get anything to work.
    I tried
    Code:
     ' set rst=conn.execute("select Watchedprofileid , p.pdjobtitle,M.WatchinguserID from tblWatches M INNER join tblother P ON M.WatchinguserID = P.UserId  where (Select Count(*) from tblWatches where WatchinguserID = " & rs("userID"))
    I also cannot get it to return results greater than 5, for example. I added >5

    where WatchinguserID = " & rs("userID") > 5)

    for example but that didnt work.


    Code:
    <%    
     dim rst
    'on error resume next
    
    set rst=conn.execute("Select count(*) from tblWatches where WatchinguserID = " & rs("userID"))
    
    if rst(0)> 0 then
            response.Write "<b> watching " & rst(0) & " </b>"
        end if
        rst.close
    %>
    Thanks in advance for any help.
    Richard
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    You need to expalin what you are trying to do. This meaningless
    Hi, I wonder if anyone knows how to do this. I need to get info from another table and cannot get anything to work.
    Post SQL code and not VB.

    Comment

    • nbiswas
      New Member
      • May 2009
      • 149

      #3
      How about this

      Code:
      ' set rst=conn.execute
      
      ("
      
      select 
      
      Watchedprofileid 
      , p.pdjobtitle
      ,M.WatchinguserID 
      
      from tblWatches M 
      
      INNER join tblother P 
      
      ON M.WatchinguserID = P.UserId  
      
      where M.WatchinguserID > 5
      
      And M.WatchinguserID = " & rs("userID")
      
      )
      Hope this helps..

      Comment

      Working...