Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 table A,B and C

A
--------------
aId bId name place etc.....
101 201 - - -
102 202 - - -
103 203 - - -
104 204

B
-------------
bId CId Name
201 1 A
202 2 A
203 1 B
204 1 C

C
-------------
cId value
1 50
2 180
3 10

I want result like

all field in A and bID which has no 180 value how i get it ?
Posted
Comments
Dj@y 16-Oct-15 3:13am    
I just want record
aId Bid B.Name
103 203 B
104 204 C
jaket-cp 16-Oct-15 4:11am    
Update you question with this bit of information - use the "Improve question" Link.
Can you also give more information on why the following should not be returned
aId Bid B.Name
101 201 A
And clarify what you mean by:
b'Coz it have 180 in another row

Include more sample data if this helps with the question

Use JOIN to link multiple tables on common fields in your query and use WHERE to filter the resultset (e.g. no 180).
Learn https://technet.microsoft.com/en-us/library/ms191430(v=sql.105).aspx[^]
 
Share this answer
 
Comments
Dj@y 16-Oct-15 3:22am    
it gives me the
bId cId name
201 1 A
but i want skip it
b'Coz it have 180 in another row
Try this,
SQL
select
a.aid, b.Bid, b.Name
from A a, B b, C c
where c.value <> 180 and a.bId = b.Id and b.cId = c.Cid

Haven't tested but this should work.

-KR
 
Share this answer
 
v2
Comments
Dj@y 16-Oct-15 3:52am    
it gives me the
bId cId name
201 1 A
but i want skip it
b'Coz it have 180 in another row
To do so, you should be very comfortable with SQL Joins[^] and SQL WHERE Clause[^].

Then you can try something like:
SQL
SELECT A.aId,A.bId,B.Name FROM A INNER JOIN B ON A.bId=B.bId INNER JOIN c ON b.cId=C.cId WHERE C.value <> 180


--Amy
 
Share this answer
 
Comments
Dj@y 16-Oct-15 3:52am    
it gives me the
bId cId name
201 1 A
but i want skip it
b'Coz it have 180 in another row
_Amy 16-Oct-15 4:02am    
How come it returned this?
Above select statement does not contain cId column even.

And if you included cId, then it should return the value you listed, because it does not contain 180.
Corporal Agarn 16-Oct-15 15:15pm    
this is what happens when they do not provide ddl :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900