dotnet0824
asked on
sql server query
i have 2 tables
student_ID IsActive slotID
1 0 1
2 1 <NULL>
3 1 2
4 1 1
5 1 <null>
Slot Table
Slot_ID desc
1 AB
2 CD
I want to have all the students who r ACTIVE(ie 1) along with their Slot Description by joining 2 tables
student_ID IsActive slotID
1 0 1
2 1 <NULL>
3 1 2
4 1 1
5 1 <null>
Slot Table
Slot_ID desc
1 AB
2 CD
I want to have all the students who r ACTIVE(ie 1) along with their Slot Description by joining 2 tables
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
where t1.isActive=1
from students s left outer join slot_table st on s.slot_id=st.slot_id
where t1.isActive=1
ASKER
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
where t1.isActive=1
this statements shows even Inactive students too..
from students s left outer join slot_table st on s.slot_id=st.slot_id
where t1.isActive=1
this statements shows even Inactive students too..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
the statement was wrong it should be
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
where s.isActive=1
But it still shows inactive students too
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
where s.isActive=1
But it still shows inactive students too
that is impossible , but you can try this
with a as (select *
from students s left outer join slot_table st on s.slot_id=st.slot_id)
select * from a
where s.isActive=1
with a as (select *
from students s left outer join slot_table st on s.slot_id=st.slot_id)
select * from a
where s.isActive=1
may be there is no inactive students or you set isActive=1 for inactive students
ASKER
sorry
I used wrong clause AND (I should be using where)
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
AND s.isActive=1
Thanks
I used wrong clause AND (I should be using where)
select *
from students s left outer join slot_table st on s.slot_id=st.slot_id
AND s.isActive=1
Thanks
from students t1 inner join slot_table t2 on t1.slot_id = t2.slot_id
where t1.isActive=1