Hey, I haven't used SQL very much and it's been a few years and I'm trying to wrap my head around a concept.Basically I've got two tables with a common column (in this case it's UserID)The structure of the table Users is basically:UserID FirstName LastName1 Jim Smith2 Nancy Orr3 Ken StephensonAnd the structure of the classes table isUserID ClassID1 AAA1 BBB2 AAA3 BBBWhat I'd like to do is select the FirstName and LastName the users table who have a UserID in both Classes and Users.The tricky part of it is that I only want to return the FirstName and LastName of userID who have multiple ClassID in the classes table. (hopefully I'm making sense when I explain this)In this case I'd like it to return just Jim Smith's name because he's the only userID who has two ClassID entries. So far I've come up with [code="sql"]select UserId, count(*) as MultipleClasses from classes group by UserID having count(*) > 1;[/code]which outputs the UserID and a colum called MultipleClasses with how many classes each ID returned has.how would I do something like[code="sql"]Select firtname, lastnamefrom userswhere Userid= The output from that initial bit finding users with multiple classes[/code]I'm definitely willing to scrap everything I've come up with so far as I feel like I'm probably barking up the wrong tree here, but any help would be appreciated!
↧