Click here to Skip to main content
15,920,217 members
Home / Discussions / Database
   

Database

 
QuestionAnother SQL/Stored Proc ? Pin
enipla16-Jun-09 6:07
enipla16-Jun-09 6:07 
AnswerTry the update statement outside the Stored Proc Pin
David Mujica16-Jun-09 7:42
David Mujica16-Jun-09 7:42 
GeneralRe: Try the update statement outside the Stored Proc Pin
enipla16-Jun-09 7:46
enipla16-Jun-09 7:46 
GeneralGood to hear Pin
David Mujica16-Jun-09 8:51
David Mujica16-Jun-09 8:51 
Questionadvance search query result? Pin
kripa2115-Jun-09 21:37
kripa2115-Jun-09 21:37 
AnswerRe: advance search query result? Pin
Niladri_Biswas17-Jun-09 20:47
Niladri_Biswas17-Jun-09 20:47 
GeneralRe: advance search query result? Pin
kripa2117-Jun-09 22:25
kripa2117-Jun-09 22:25 
AnswerRe: advance search query result? [modified] Pin
Niladri_Biswas25-Jun-09 3:02
Niladri_Biswas25-Jun-09 3:02 
If I have clearly understood your problem, you want to display only those cars which have got all the amenities.

I created 3 tables as what you specified.
Here I am depicting the junction table( tblCarAmnesty ) which is having 2 columns viz. CarCode & AmmCode [ both of type int ]

The values are as under

CarCode AmmCode
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
4 1
5 2
5 3
6 1
6 2
6 3

As per your requirement, Only car code 1,2 and 6 will only appear.

Here is the query

SELECT C.CARCODE
FROM (
			SELECT A.CARCODE,A.AMMCODE 
			FROM (SELECT CARCODE,AMMCODE FROM dbo.tblCarAmnesty 
			WHERE AMMCODE = 1) A

			INNER JOIN 

			(SELECT CARCODE,AMMCODE FROM dbo.tblCarAmnesty 
			WHERE AMMCODE = 2) B

			ON A.CARCODE = B.CARCODE) C

		INNER JOIN 

(SELECT CARCODE,AMMCODE FROM dbo.tblCarAmnesty 
WHERE AMMCODE = 3) D

ON C.CARCODE = D.CARCODE


And here is the output

CARCODE
1
2
6
Let me know in case of any concerns

Hope this helps.
Smile | :)

Niladri Biswas

modified on Friday, June 26, 2009 12:27 AM

GeneralRe: advance search query result? Pin
kripa2125-Jun-09 22:41
kripa2125-Jun-09 22:41 
GeneralRe: advance search query result? [modified] Pin
Niladri_Biswas27-Jun-09 19:11
Niladri_Biswas27-Jun-09 19:11 
GeneralRe: advance search query result? Pin
kripa2128-Jun-09 20:39
kripa2128-Jun-09 20:39 
GeneralRe: advance search query result? Pin
Niladri_Biswas28-Jun-09 23:24
Niladri_Biswas28-Jun-09 23:24 
QuestionHow to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
LTMKH15-Jun-09 19:34
LTMKH15-Jun-09 19:34 
Answer[Message Deleted] Pin
kripa2115-Jun-09 22:59
kripa2115-Jun-09 22:59 
QuestionRe: How to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
LTMKH15-Jun-09 23:57
LTMKH15-Jun-09 23:57 
AnswerRe: How to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
Isaac Gordon15-Jun-09 23:45
Isaac Gordon15-Jun-09 23:45 
QuestionRe: How to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
LTMKH16-Jun-09 0:19
LTMKH16-Jun-09 0:19 
AnswerRe: How to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
Vimalsoft(Pty) Ltd16-Jun-09 22:47
professionalVimalsoft(Pty) Ltd16-Jun-09 22:47 
AnswerRe: How to Clear record very fastly ( use alitle script ) in SQL server 2005? Pin
Niladri_Biswas25-Jun-09 5:32
Niladri_Biswas25-Jun-09 5:32 
Questionauthentication databse Pin
jainiraj15-Jun-09 6:04
jainiraj15-Jun-09 6:04 
AnswerRe: authentication databse Pin
Aman786Singh17-Jun-09 3:17
Aman786Singh17-Jun-09 3:17 
GeneralRe: authentication databse Pin
jainiraj18-Jun-09 4:43
jainiraj18-Jun-09 4:43 
QuestionProblem while accessing the committed data + sql server 2005 Pin
Pankaj Garg15-Jun-09 2:39
Pankaj Garg15-Jun-09 2:39 
AnswerRe: Problem while accessing the committed data + sql server 2005 Pin
himanshu256115-Jun-09 2:52
himanshu256115-Jun-09 2:52 
GeneralRe: Problem while accessing the committed data + sql server 2005 Pin
Pankaj Garg15-Jun-09 3:18
Pankaj Garg15-Jun-09 3:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.