Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2004
    Posts
    39

    Unanswered: left join question

    I have a left join that doesn't suit my request.

    select * from A
    left join B
    on A.x=B.x

    The problem is that for a specific record in A we can find 1 or more entries in B. What I want is to return only the 1st entry found on B.
    thx

  2. #2
    Join Date
    Nov 2004
    Posts
    39
    I made it:

    select *,
    (
    select top 1 * from B
    where A.x=B.x
    )
    from A

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Bzzzzzzzz...sorry. Thanks for playing. "The order of the data in a database has no meaning", or something like that.
    Without an ORDER BY statement, you cannot rely on getting the same results every time you run this query. You need to define what you mean by 1st entry.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    The physical order of data in a database has no meaning

    Bzzzzzzzz...sorry. Thanks for playing.
    You crack me up
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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