• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help in SQL Query

 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

There are two tables tableA and tableB and I need a complement of tableA with tableB , I mean, I want to return all the rows which are absents in tableB, like




Here "tableA COMPLEMENT tableB" results into following rows,



My first try,

Its working , but I'm not sure whether its good or not !
So any alternatives??
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are close. Better not concatenate. That is messy.

There are several options:



or, in oracle:
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thanks, we are concentrating more on first option as we are using MS SQL SERVER.
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think operations like "Union", "Minus", "Intersect" are standard Relational Operations that all databases should adhere to.
not sure why SQL Server doesn't support this.
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul Babbar wrote:I think operations like "Union", "Minus", "Intersect" are standard Relational Operations that all databases should adhere to.
not sure why SQL Server doesn't support this.



Yes, we checked out this basic set operation first, But SQL SERVER dosen't supports MINUS (Yeh, Its support UNION and INTERSECTION). Actually there in no keyword like, minus. And interestingly doesn't have CONCAT operator (Query is constructed on MySQL first) too.
 
author & internet detective
Posts: 41919
910
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some database use an alternate keyword for "minus." For example, db2 uses "except." I did check online and SQL Server doesn't have one. Which means this post isn't so much for you as it is for the db2 user who stumbles across this thread.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic