No.1 | | 855 bytes |
| 
Wed, 2006-08-23 at 22:23 +0200, spacemarc wrote:
Hi,
I have a query like this:
SELECT table1.*,(
SELECT ****( field2 )
FRM table2
WHERE id=10
) AS total
FRM table1
GRUP BY id
LIMIT 1
but the subqueries do not work with mysql < 4.1. How can I convert it
(or make to work) in MySQL 3.x, 4.0 possibly in one only query?
Your query doesn't show any relationship between the two tables (via a
join condition or correlation) so you would have to do two queries
(which is exactly what your original query does anyway:
SELECT ****(field2):=@counter FRM table2 WHERE id = 10;
SELECT table1.*, @counter as total
FRM table1
LIMIT 1;
Note that I took out the GRUP BY clause, which is pointless given the
query's structure of returning the first id column.
Jay