Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Special INNER JOIN clause required
Message
 
 
À
13/03/2009 20:20:47
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01387986
Message ID:
01388010
Vues:
60
This message has been marked as the solution to the initial question of the thread.
I'm not really sure what you're after . Will this work for you?
SELECT Member.FirstName 
	FROM Member 
	WHERE EXISTS (SELECT 1 FROM Friend 
  		    WHERE Friend.NoMember = Member.NoMember OR Friend.NoMember2 = Member.NoMember)
		AND Member.NoMember = 1	
>I need a special INNER JOIN which I cannot find a way to do. Basically, I have a table having NoMember and NoMember2 fields. So, if I would look into my profile, I could see records where NoMember is to my ID or some records that NoMember2 is also to my ID. From that, I need to create a list where I would show the other Member.FirstName field.
>
>If I would do somelike like this, I would only get the records where NoMember is to my ID:
>
>
>SELECT Member.FirstName FROM Friend
> WHERE Friend.NoMember=1 OR Friend.NoMember2=1
> INNER JOIN Member ON Friend.NoMember=1
>
>
>To achieve a combination of both fields, I would need something similar to this:
>
>
>SELECT Member.FirstName FROM Friend
> WHERE Friend.NoMember=1 OR Friend.NoMember2=1
> INNER JOIN Member ON (Friend.NoMember=1 OR Friend.NoMember2=1)
>
>
>However, this would create a duplicate of all records I would get in the first SQL. What I need is to obtain the same amount of records as the first SQL but to show the relation on the other field which ever is not having NoMember=1 or NoMember2=1.
>
>Is this possible?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform