RE: Subquery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It doesn't work because MySQL version 3.23.50 does not support sub-select
statement.

http://dev.mysql.com/doc/mysql/en/subqueries.html

And

How to re-write it in MySQL < 4.1

http://dev.mysql.com/doc/mysql/en/rewriting-subqueries.html


Nandar wrote on Monday, 19 September 2005 1:03 PM:

> i hope it's helping
> 
> sql code:
> 
> UPDATE T020Employee SET T020FaxNo = T010FaxNo FROM T020Employee a JOIN 
> T010Company b ON a.T020CoCd =b.T010CoCd
> 
> ----- Original Message -----
> From: "Ng Hwee Hwee" <hhwee@xxxxxxxxxxx>
> To: "PHP DB List" <php-db@xxxxxxxxxxxxx>
> Sent: Monday, September 19, 2005 9:14 AM
> Subject:  Subquery
> 
> 
> hi,
> 
> can some one enlighten me on what is wrong with my query?
> 
> I want to set the fax number of all the employees of a particular 
> company to the company's fax number. This is because the employees do 
> not have personal fax machines, thus instead of just leaving T020FaxNo 
> blank, I want to update it with the company's fax number.
> However, the following
> doesn't work?!
> i'm
> hoping i don't have to write a PHP while loop to do this simple task! 
> =(
> 
> UPDATE T020Employee SET T020FaxNo = (  SELECT T010FaxNo FROM 
> T010Company WHERE  T010CoCd =  'XXX'  ) WHERE T020CoCd =  'XXX'
> 
> MySQL version: 3.23.58. PHP version: 4.3.4.
> My database structure is:
> T010Company
> ===========
> T010CoCd (primary key)
> T010CoName
> T010Address
> T010TelNo
> T010FaxNo
> 
> T020Employee
> ===========
> T020CoCd (primary key, linking to T010CoCd) T020EmpCd (primary key) 
> T020JobTitle T020TelNo T020FaxNo
> 
> Thanks so much!
> Hwee

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux