What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 4848 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > Use of except in select query ...
Rajni.Shekhar

Use of except in select query

 Code Snippet posted by: Rajni.Shekhar | Posted on: 4/18/2012 | Category: SQL Server Codes | Views: 344 | Status: [Member] | Points: 40 | Alert Moderator   


Select all cities from emp table except from city table.

CREATE TABLE EMP  (ID    INTEGER NOT NULL,

NAME VARCHAR(20) NOT NULL,
CITY VARCHAR(20) NULL)


insert into EMP values(1, 'EMP1', 'DELHI')
insert into EMP values(2, 'EMP2', 'CHENNAI')
insert into EMP values(3, 'EMP3', 'PUNE')
insert into EMP values(4, 'EMP4', 'AGRA')
insert into EMP values(5, 'EMP5', 'CHENNAI')

CREATE TABLE CITY(ID INT IDENTITY, CITY_NAME VARCHAR(20))

insert into CITY values('CHENNAI')

SELECT CITY FROM EMP EXCEPT SELECT CITY_NAME FROM CITY


Thanks,
Rajni Shekhar
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 12:55:35 AM