Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to use select for this condition

Author  Topic 

venkateshap87
Starting Member

1 Post

Posted - 2009-07-11 : 11:51:09
i have a student details table and staff details table and a library table now i need to fetch the code in the library and print the names from student detail table and staff details table

can i query like this

select library.id, (student_details.stud_name or staff_details.staff name , .....

venkatesh

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-11 : 13:39:46
You have to join the tables.
If you can show table structure and wanted output (best with example data) we can show you the select.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-12 : 03:55:13
something like

SELECT l.memberid
coalesce(sd.staffname,std.studentname) as membername,
coalesce(sd.staffcode,std.studentcode) as membercode,
...
FROM library l
left join staffdetails sd
on sd.staffid=l.memberid
left join studentdetails std
on std.studentid=l.memeberid

i've just given a sample query with some column names but you need to replace actual table and column names in it
Go to Top of Page
   

- Advertisement -