Trying to perform MINUS operation in MySQL -


i trying perform minus operation in mysql.i have 3 tables:

  1. one service details
  2. one table states service offered in
  3. another table (based on zipcode , state) shows service not offered.

i able output 2 select queries separately. need combined statement gives output 'select query_1 - select query_2'.

service_details table service_code(pk) service name

servicing_states table service_code(fk) state country pk(service_code,state,country)

exception table service_code(fk) zipcode state pk(service_code,zipcode,state)

the tables have have same columns, think can achieve looking except... except except works in standard sql! here's how in mysql:

select * servicing_states ss not exists     ( select * exception e ss.service_code = e.service_code); 

http://explainextended.com/2009/09/18/not-in-vs-not-exists-vs-left-join-is-null-mysql/

standard sql

select * servicing_states except select * exception; 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -