SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help limiting inner join

    Hello,

    I need help limiting inner join.

    my query:

    Code:
    SELECT uid
    FROM users AS u
    INNER JOIN files AS x ON u.fid = x.fid
    WHERE u.left = '0'
    AND x.flags = '0'
    AND u.active = '1'
    ORDER BY `u`.`uid` ASC
    result:
    uid
    3
    3
    3
    3
    7
    47
    47
    47
    47
    47
    47
    47
    47
    47
    47


    I need to limit INNER JOIN to 5 only. like:

    uid
    3
    3
    3
    3
    7
    47
    47
    47
    47
    47


    If anyone could help me I will be very grateful

    thank you

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Something tells me this is only a very simplified version of the real query.
    I mean, what use is a list of duplicated userid's, whatever the number?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,217
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by SamiBH View Post
    I need to limit ...
    hint: LIMIT

    it's in da manual

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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