Welcome Guest, Not a member yet? Register   Sign In
Price database and confusing SQL query
#3

[eluser]obiron2[/eluser]
looks good to me.

SQL to get latest prices

select p.merchant_id,p.price,max(p.created_on),m.name,m.description
from prices p
join merchant m on p.merchant_id = m.id
where p.product_id = $productID
group by p.merchant_id,m.name,m.description
order by m.name


SQL to get prices at a specific date

select p.merchant_id,p.price,max(p.created_on),m.name,m.description
from prices p
join merchant m on p.merchant_id = m.id
where p.product_id = $productID
and p.created_on <= $PriceDate
group by p.merchant_id,m.name,m.description
order by m.name

Obiron


Messages In This Thread
Price database and confusing SQL query - by El Forum - 02-17-2009, 05:13 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 05:55 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 06:04 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 06:43 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 07:39 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 10:00 AM
Price database and confusing SQL query - by El Forum - 02-17-2009, 01:39 PM
Price database and confusing SQL query - by El Forum - 02-17-2009, 03:06 PM
Price database and confusing SQL query - by El Forum - 02-17-2009, 03:18 PM
Price database and confusing SQL query - by El Forum - 02-17-2009, 03:40 PM
Price database and confusing SQL query - by El Forum - 02-17-2009, 11:14 PM
Price database and confusing SQL query - by El Forum - 02-18-2009, 03:10 AM
Price database and confusing SQL query - by El Forum - 02-18-2009, 06:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB