![]() | |
#11
| |||
| |||
|
|
SELECT s1.article, s1.dealer, s1.price FROM shop s1 LEFT JOIN shop s2 ON s1.article = s2.article AND s1.price < s2.price WHERE s2.article IS NULL; Why is there no more direct way to do this? Something like "Scan table; if new article: add to result; else if new price higher: update result; else ignore entry." Whilst, dependent on the data, this may not always be the fastest method, I do not see that it requires any more combinations than your proposal. |
#12
| |||
| |||
|
|
Christopher M.: I'm an old-school SQL guy, just getting into MySQL now. Well, welcome to MySQL! Any tips on selecting group-wise maximums? http://dev.mysql.com/doc/refman/5.1/...group-row.html Should I avoid subqueries, and nested joins, and instead use a cursor? No, you shouldn't. There's no such rule as "avoid A, use B" as long as you don't look at the parameters of your specific case. Why don't you simply fill a test set-up with data, and try both alternatives? See what is faster, AND have a look at what you're comfortable with, when you're the one who is going to keep working on the application, even after several years. After all, even the fastest query is worthless, if you're not able to perform maintenance in the future. |
#13
| |||
| |||
|
|
"Erick T. Barkhuis" <erick.use-net (AT) ardane (DOT) c.o.m> wrote in message news:9qfat4FmvmU1 (AT) mid (DOT) individual.net... Christopher M.: I'm an old-school SQL guy, just getting into MySQL now. Well, welcome to MySQL! Any tips on selecting group-wise maximums? http://dev.mysql.com/doc/refman/5.1/...group-row.html Should I avoid subqueries, and nested joins, and instead use a cursor? No, you shouldn't. There's no such rule as "avoid A, use B" as long as you don't look at the parameters of your specific case. Why don't you simply fill a test set-up with data, and try both alternatives? See what is faster, AND have a look at what you're comfortable with, when you're the one who is going to keep working on the application, even after several years. After all, even the fastest query is worthless, if you're not able to perform maintenance in the future. I tried joining to a nested SELECT statement, because it was fastest. I'm also using the limit statement. I'm getting inconsistent results. W. Pooh (AKA Winnie P.) |
![]() |
| Thread Tools | |
| Display Modes | |
| |