Re: Crappy results from query
| From: | Ryan A | Date: | Wed, 18 Feb 2004 15:22:18 +0000 |
| Subject: | Re: Crappy results from query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-178112@lists.php.net to get a copy of this message | ||
On 2/18/2004 3:32:31 PM, Duncan Hill (dhill@cricalix.net) wrote:
> On Wednesday 18 February 2004 14:21, Ryan A wrote:
> > Hey,
> > Cant really understand this, can someone point out where I'm going wrong
> > please?
> >
> > The idea is simple, I have 3+ names of clients in the database, each
client
> > has multiple records
> > with the same order_id and name (because they are registered with
multiple
> > products):
> > eg:
> > order_id Name Product
> > 565454 Ryan 211
> > 565454 Ryan 11
> > 565454 Ryan 617
> > 845874 susan 44
> > 845874 susan 857
> > 698457 Jacob 211
>
> Yuck? :)
>
> Table customers:
> customerid int
> fname char
> lname char
> .
> .
>
> Table orders
> orderid int
> ref_customerid int
> product int
> quantity int
>
> select distinct customerid, fname from customers, orders where
> customerid=ref_customerid;
>
> Should work. Totally untested of course. This approach lets you fix
customer
> names etc without having to fix all records in the orders db.
Hi,
Thanks for replying.
Logically, customers would be in one table and orders in another,
unfortunatly I was
not called from the beginning for this project and have to work with data
thats already
there in these tables...:-(
Given the present state of data in the tables...what do you suggest I do to
get those results
in that way?
Thanks,
-Ryan