[prog] Sql query
Dan
dan at cellectivity.com
Tue Jul 12 19:02:36 EST 2005
> I'm using a mysql-server, version 3.23, so it doesn't have
> subqueries yet.
Even if it had subqueries, you'd need to be somewhat of a database guru
to find a *good* solution to this one.
Here's a solution that's a bit of a hack, but at least it doesn't
require issuing queries in a loop.
SELECT * FROM product, period WHERE product.id=period.productid ORDER BY
product.id, period.startdate DESC;
Then loop through the results and, when you encounter a new product.id,
you know that you have the last period for that product.
--
Q) Why do C programmers put all the code in the "for" statement?
A) Because they can!
- Todd Stevens
More information about the Programming
mailing list