Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Location
    India
    Posts
    109

    Unanswered: Converting a subquery into a join query

    I have a subquery which does not work in the mysql version that my client has installed.

    [SQL]
    SELECT user_name from users
    where user_id in
    (select poster_id
    from posts
    order by post_created_on
    desc limit 0,10)
    [/SQL]

    How to convert this into a query with join?

    I tried the below syntax and it doesnt work.

    select user_name from users, posts where users.user_id=posts.poster_id
    group by posts.poster_id order by post_created_on
    desc limit 0,10

  2. #2
    Join Date
    Aug 2003
    Location
    India
    Posts
    109
    No problem. I tried this and it seems to work.

    SELECT user_name,
    max( unix_timestamp( poll_created_on ) ) AS mx
    FROM users
    INNER JOIN posts ON users.user_id = posts.poster_id
    GROUP BY user_name
    ORDER BY mx DESC

Posting Permissions

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