Trying to perform MINUS operation in MySQL -
i trying perform minus
operation in mysql.i have 3 tables:
- one service details
- one table states service offered in
- 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
Post a Comment