MySQL JOIN Statement - Referenced Field in same Table -


how list of orders in table except (orders has been referenced , type of -1)

orders table:

id   |   reference_id  | type ----------------------------------  1    |                 | 1 ----------------------------------  2    |                 | 1 ----------------------------------  3    |   1             | -1 ---------------------------------- 

something like:

list = arraylist();  if( order.type > 0 ){     if( order.id != other_order.reference_id )         list.add(order) } 

how in mysql statement?

also same result of statement using join....etc:

select * orders a.type > 0 , not exists  (select * orders b a.id = b.ref_id) 

thanks

this give records referenced , valid

select *    yourtable         inner join yourtable b                 on a.reference_id = b.order_id   b.reference_type > 0;  

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -