* fbeltran
> According to documentation, in MySQL version 4.0, it is possible to use 
> sub-selects, but i haven't found the correct syntax... 

Like others have said, it's from version 4.1:

<URL: http://www.mysql.com/doc/en/ANSI_diff_Subqueries.html >

> Does any one know how to do this?
> I need someting like this:
> 
> Select a, (select sum(b) from T2 where T2.a=T1.a) as b from T1

A simple join and a GROUP clause should do it:

SELECT T1.a, SUM(b) AS b
  FROM T1
  LEFT JOIN T2 USING(a)
  GROUP BY T1.a

-- 
Roger

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to