[Hidden-tech] Mind Puzzle For All You SQL Gurus

David Mertz, Ph.D. mertz at gnosis.cx
Wed Dec 14 14:48:59 EST 2005


> I am trying to write a query on two tables, with a many to one 
> relationship.
> Let us call the primary table A, and the foreign key table B.  For each
> record in table A, I would like 1 (and only 1) corisponding record from
> table B.  The 1 record should be the result of the top record from a 
> sort on
> table B.
> The use of cursors will be considered cheating.  I think this is 
> possible,
> but I am open to someone proving it is not as well.

Rather simple.  Something like:

  SELECT * FROM A NATURAL JOIN B SORT BY B.Foo LIMIT 1;




Google

More information about the Hidden-discuss mailing list