Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-02-2012, 11:52 PM #1
- Join Date
- Mar 2012
- Thanked 0 Times in 0 Posts
Mysql query newest entry for each idproduct?PHP Code:
$query = ("SELECT *
ON operators.idoperators = products.idoperator JOIN results
ON products.idProducts = results.idproducts
WHERE (products.idProducts ='2'
OR products.idProducts ='5'
OR products.idProducts ='9'
OR products.idProducts ='10'
OR products.idProducts ='12'
OR products.idProducts ='13')
ORDER BY date DESC
How can I only show the newest row for each idProduct in the WHERE statement?
09-03-2012, 08:41 PM #2
It's not easy. You have to create a UNION of 6 separate SELECTs, one for each idProducts.
You are doing SELECT * (which is a really bad idea) and you don't show what table date is from, so I can't tell you the exact syntax to use.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.