For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > October 2004 > Newbie question...display records based on field value









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Newbie question...display records based on field value
Fred

2004-10-31, 3:55 pm

My dbase has two types of 'customers'

They are 'players' and 'coaches.'

Both types are 'customers' and have several basic fields in common.

But each also has distinct fields.

How do I write the code that selects from the overall 'customers'
table only those records which have "yes" in the "coach" field?
Tim Van Wassenhove

2004-10-31, 8:55 pm

In article <bb7ad7bb.0410311141.3063eb34@posting.google.com>, Fred wrote:
> My dbase has two types of 'customers'
>
> They are 'players' and 'coaches.'
>
> Both types are 'customers' and have several basic fields in common.
>
> But each also has distinct fields.
>
> How do I write the code that selects from the overall 'customers'
> table only those records which have "yes" in the "coach" field?


Assuming you have

customer(customer_ID, common fields);
player(customer_ID, fields for players);
coach(customer_ID, fields for coaches)

SELECT *
FROM coach
INNER JOIN customer ON coach.customer_ID=customer.customer_ID
WHERE coach.foo='YES';

--
Met vriendelijke groeten,
Tim Van Wassenhove <http://www.timvw.info>
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com