All pastes #466659 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-01 03:10 UTC
rendered paste body
Check the 'orders_products' in the 'from' statement... it is being called twice.. once as 'opa' and next as 'opb'   THEN if you check in 'where' condition... "opa.products_id = '870'"  and "opb.products_id != '870'" 


select 
	p.products_id, p.products_image 
from 
	orders_products opa, 
	orders_products opb, 
	orders o, 
	products p 
where 
	opa.products_id = '870' and 
	opa.orders_id = opb.orders_id and 
	opb.products_id != '870' and 
	opb.products_id = p.products_id and 
	opb.orders_id = o.orders_id and 
	p.products_status = '1' 
group by 
	p.products_id 
order by 
	o.date_purchased 
desc 
limit 
	6


aren't they both contradicting each other.. this statement runs.. but I isn't this just a overhead..