I'm a comparative MySQL newbie who is struggling with sub-selects. In
other DBMS's, I can use sub-selects to return a set that I can use in a
condition of a WHERE clause. An example is the recent query by Ciprian
Trofin about finding the cheapest price of a product. In other DBMS's
I would use:
SELECT a.id, a.product, a.price, a.store
FROM mytable a
WHERE a.price <= ALL (
SELECT b.price FROM mytable b
WHERE a.id = b.id
)
However, this doesn't work in MySQL. I've tried using the LEAST
function instead of ALL, which triggered an exception at the
sub-select.
The MySQL docs say that sub-selects are due for implementation in 4.x.
In the meantime, is there a way to emulate the preceding statement
that won't cause concurrency problems?
TIA,
--
Geoff Lane
Cornwall, UK
[EMAIL PROTECTED]
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php