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
 Site Related Forums
 Article Discussion
 query problem

Author  Topic 

sanjeebparida
Starting Member

1 Post

Posted - 2005-10-10 : 07:07:11
suppose there are two tables emp and amp1
having fields as
table emp
empname empno dessig
sanjeeb 111 manager
rajeeb 112 engineer
-----------------
table emp1
empname empno
sanjeeb 111
rajeeb 112
rohit 345
-------------------
now my query is how i'll select
q1>get me the rows available in emp and not in emp1
q2>get me the rows available in emp1 and not in emp
q3>get me the columns available in emp but not in emp1
q4>get me the columns available in emp1 but not in emp

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-10 : 07:25:30
[code]1 Select * from emp T where not exists(Select * from emp1 where empname=T.empname)
2 Exchage table names from 1
3 select Column_name from information_schema.columns T where table_name ='emp'
and not exists(select * from information_schema.columns where table_name='emp1' and column_name=T.Column_name)
4 Exchage table names from 3[/code]
Refer these for basics of SQL queries
www.sqlcourse2.com
http://www.firstsql.com/tutor.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-10-10 : 08:35:11
Hmmm....some marks for persistance!
None....for originality.

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56249
Go to Top of Page
   

- Advertisement -