Re: Subquery
| From: | Ng Hwee Hwee | Date: | Mon, 19 Sep 2005 03:50:27 +0000 |
| Subject: | Re: Subquery | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40302@lists.php.net to get a copy of this message | ||
hi all,
i found the solution! it's so easy actually.. i think my brain is not
functioning well on a Monday morning!! ;p
UPDATE T020Employee, T010Company
SET T020FaxNo = T010FaxNo
WHERE T020CoCd = T010CoCd
thanks bastien and nandar for your help! =)
hwee
----- Original Message -----
From: "Bastien Koert" <bastien_k@hotmail.com>
To: <hhwee@towa.com.sg>; <php-db@lists.php.net>
Sent: Monday, September 19, 2005 11:30 AM
Subject: RE: [PHP-DB] Subquery
> only versions 4.1 and above support subqueries...
>
> bastien
>
> >From: "Ng Hwee Hwee" <hhwee@towa.com.sg>
> >To: "PHP DB List" <php-db@lists.php.net>
> >Subject: [PHP-DB] Subquery
> >Date: Mon, 19 Sep 2005 10:14:34 +0800
> >
> >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
>