Select statement for username and userid from a table & sort userid from another tabl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Donna Horton
    New Member
    • Sep 2010
    • 1

    Select statement for username and userid from a table & sort userid from another tabl

    If I create a Select statement to select a username and userid from a table then I want to select the userid from another table and sort on the userid for example I sorted on the email usernames and userIDs, then I wanted to select the userids from another table and search for how many messages were sent from the user id in 1 day. Can I use the group function or is there a better what to search on this? If so, please tell me the best way to accomplish this.

    Thanks!!
  • Oralloy
    Recognized Expert Contributor
    • Jun 2010
    • 988

    #2
    Donna.

    Conceptually I think you're looking for something like this?

    Code:
    SELECT t1.username, t1.userid, COUNT(t2.*), t2.date
      FROM t1 INNER JOIN t2 ON t1.userid = t2.userid
      ORDER BY t1.userid
      GROUP BY t2.date

    Comment

    • alemgeb
      New Member
      • Dec 2011
      • 2

      #3
      The question needs a bit clarification. If the two tables are having the same structure and records are put on both tables you can use the union or union all operator that will put all the records from the two tables and then use the count function as count(*) or count(userid) that will give you the total number of abservation. The second option is as described by Donna join the tables and use the count function.
      Alemayehu G. Desta

      Comment

      Working...