This mirrors a problem I have faced exactly. Using MySQL 4, I have had to do this with two queries, finding no other way to do it. If your SQL server allows subselects as part of a join's where clause, then you're all set. (If you do find a solution to this, please post it back to the list.) Good luck! Seth On Dec 13, 2005, at 6:50 PM, Ben Liyanage wrote: > ** Be a Good Dobee and help the group, you must be counted to post . > ** Fill out the survey/skills inventory in the member's area. > I have a sql challenge for those of you who wish to accept it. > > 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. > > Good luck. > > Ben Liyanage > ben at smartankgroup.com > 410.336.2464 > > _______________________________________________ > Hidden-discuss mailing list - home page: http://www.hidden-tech.net > Hidden-discuss at lists.hidden-tech.net > > You are receiving this because you are on the Hidden-Tech Discussion > list. > If you would like to change your list preferences, Go to the Members > page on the Hidden Tech Web site. > http://www.hidden-tech.net/members