Re: table relationship
| From: | David Newcomb | Date: | Thu, 07 Sep 2000 17:39:37 +0000 |
| Subject: | Re: table relationship | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-2702@lists.php.net to get a copy of this message | ||
Manuel,
select sales.custid,custname,date,purchase
from customer,sales
where sales.custid = customer.custid;
It is better to call userid some thing different in each table so that
you don't have to use aliasing.
eg cus_userid and sal_userid
hth,
David.
----- Original Message -----
From: Manuel <manuel@buyee.com.sg>
To: <php-db@lists.php.net>
Sent: Wednesday, September 06, 2000 6:13 PM
Subject: [PHP-DB] table relationship
> I have two tables, one customer and one sales.
>
> Table: Customer
> custid - primary key
> custname
> custadd
>
> Table: Sales
> custid - primary key
> date
> purchases
>
> Question:
> How do I extract custname from customer table when I do a search in the
> sales table?
> I would like to have these fields:
> 1) custid
> 2) custname
> 3) date
> 4) purchases
>
> Do I need to set the relationship for the two tables?
>
> Any help would be appreciated.
>
> Thank you.