Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL depths of a SQL virgin 1

Status
Not open for further replies.

louize

Technical User
Apr 22, 2001
24
GB
i've setting up a simple databases that records crew member that take part in sailing. the main form has a key field-"Sailno", whereas the sub table which contains the various crew taking part has a key feild of "SailingID"

I'm tring to run an SQL query that find who have sailed within a set time but the results brings repeated answers if the one person has worked afew days

heres my pathetic attempt X-)

SELECT CREWtbl.CForname
From CREW_SAILtbl, CREWtbl
WHERE CREWtbl.CrewNo=CREW_SAILtbl.CrewNo
AND CREW_SAILtbl.SailNo IN

(SELECT CrewNo
FROM CREW_SAILtbl
GROUP BY CrewNo
HAVING COUNT(*)<4);
 
Without looking too closely, if you change SELECT CREWtbl.CForname to SELECT DISTINCT CREWtbl.CForname, then you ought to get the names only once.

Always pleased to help a virgin out. Peter Meachem
peter@accuflight.com
 
peter darling ur a star!!! it worked a treat and i'm forever grateful u source of knowledge u!! ;-)
 
If you are going to be as nice as that, you ask me any thing you like. Happy to help. Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top