Results 1 to 2 of 2

Thread: Sql Count Query

  1. #1
    Join Date
    Apr 2007

    Sql Count Query

    Hi guys,

    i have the following query

    $sql = "SELECT count(article_auther_user_id) as number_of_posts, mi_users.user_name, mi_users.user_id FROM mi_article, mi_users WHERE mi_users.user_id = mi_article.article_auther_user_id GROUP BY article_auther_user_id ORDER BY user_name DESC";

    Basically what i want it to do is to count the number of "article_auther_user_id" which is in the "mi_article" table, then match that info to mi_users table and return the user_name.

    Can someone please help me out.

  2. #2
    Join Date
    Jul 2008
    Try this:

    SELECT a.user_name, a.user_id,
    (SELECT COUNT(*) FROM mi_article WHERE article_auther_user_id = a.user_id)
    FROM mi_users a

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center