Skip to main content
Removed EDIT see http://meta.stackexchange.com/a/127655; incorporated comment
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPTEXCEPT (aka MINUS) where the RDBMS supports it
 .
This should give the same execution plan as NOT EXISTSNOT EXISTS

DECLARE @NoDateWanted date = '20110922';

SELECT id, @NoDateWanted AS tarih
FROM kimlik
EXCEPT
SELECT id, @NoDateWanted 
FROM siparis
WHERE tarih = @NoDateWanted;

Edit: Now with added corrections.

You'll have to add the date filter in as a constant.
  
When you check for "no rows" there is no row to pull the data from of course.

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPT where the RDBMS supports it
  This should give the same execution plan as NOT EXISTS

DECLARE @NoDateWanted date = '20110922';

SELECT id, @NoDateWanted AS tarih
FROM kimlik
EXCEPT
SELECT id, @NoDateWanted 
FROM siparis
WHERE tarih = @NoDateWanted;

Edit: Now with added corrections.

You'll have to add the date filter in as a constant.
  When you check for "no rows" there is no row to pull the data from of course

The 4th way is to use EXCEPT (aka MINUS) where the RDBMS supports it.
This should give the same execution plan as NOT EXISTS

DECLARE @NoDateWanted date = '20110922';

SELECT id, @NoDateWanted AS tarih
FROM kimlik
EXCEPT
SELECT id, @NoDateWanted 
FROM siparis
WHERE tarih = @NoDateWanted;

You'll have to add the date filter in as a constant. 
When you check for "no rows" there is no row to pull the data from of course.

added 32 characters in body
Source Link
gbn
  • 70.1k
  • 8
  • 165
  • 242

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPT where the RDBMS supports it
This should give the same execution plan as NOT EXISTS

DECLARE @NoDateWanted date = '20110922';

SELECT id, ad@NoDateWanted AS tarih
FROM kimlik
EXCEPT
SELECT id, 'dummy'@NoDateWanted 
FROM siparis
WHERE tarih = @NoDateWanted;

Edit: Now with added corrections.

You'll have to add the date filter in as a constant.
When you check for "no rows" there is no row to pull the data from of course

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPT where the RDBMS supports it
This should give the same execution plan as NOT EXISTS

SELECT id, ad
FROM kimlik
EXCEPT
SELECT id, 'dummy'
FROM siparis

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPT where the RDBMS supports it
This should give the same execution plan as NOT EXISTS

DECLARE @NoDateWanted date = '20110922';

SELECT id, @NoDateWanted AS tarih
FROM kimlik
EXCEPT
SELECT id, @NoDateWanted 
FROM siparis
WHERE tarih = @NoDateWanted;

Edit: Now with added corrections.

You'll have to add the date filter in as a constant.
When you check for "no rows" there is no row to pull the data from of course

Source Link
gbn
  • 70.1k
  • 8
  • 165
  • 242

Following on from Andrew Bickerton's answer...

The 4th way is to use EXCEPT where the RDBMS supports it
This should give the same execution plan as NOT EXISTS

SELECT id, ad
FROM kimlik
EXCEPT
SELECT id, 'dummy'
FROM siparis