From: | <operationsengineer1(at)yahoo(dot)com> |
---|---|
To: | pgsqlnovice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: SQL Statement Help Needed |
Date: | 2005-12-06 00:20:22 |
Message-ID: | 20051206002022.37586.qmail@web33308.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
to the OP (i couldn't find it, so i'm replying to this
note),
have you thought about normalizing your data structure
a bit further?
your table structure currently appears to be:
table_employees
employee_id
employee_name
home_phone
work_phone
cell_phone
pager
fax
etc...
you could set it up as follows...
table_employees
employee_id
employee_name
table_phone_number
phone_number_id
phone_number
type_id
table_type_phone_number (note: type_name is where
"home", "work", "fax", etc. gets entered)
type_id
type_name
table_link_employee_phone_number
employee_id
phone_number_id
the reason for doing this is that you eliminate
database dead space (people that don't have faxes
won't store a null in the db (i think it is null) and
the db won't have to manage the null values).
best of luck.
--- Frank Bax <fbax(at)sympatico(dot)ca> wrote:
> At 04:12 AM 12/4/05, Michael Avila wrote:
> >I have a table with members named members. Each
> member has only 1 record.
> >A member can have more than one telephone number
> (home,
> >work, cell, pager, fax, etc.). I want to print out
> the telephone numbers of
> >the members. Is it possible to do it in one SQL
> statement like with a JOIN
>
> Yes.
>
> >do I need to get the members and then loop through
> the
> >membertelephones to get the telephone numbers?
>
> No.
>
> >Is it possible to do a JOIN
> >with a table with one record with a table with
> multiple records?
>
> Yes.
>
>
> >SELECT * FROM member
> >
> >SELECT * FROM membertelephone WHERE member_id = the
> id from the above SELECT
>
> http://en.wikipedia.org/wiki/Join_%28SQL%29
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please
> send an appropriate
> subscribe-nomail command to
> majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list
> cleanly
>
__________________________________________
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | operationsengineer1 | 2005-12-06 01:13:59 | Re: fk problems with 0..n relations |
Previous Message | Mike Ellsworth | 2005-12-06 00:14:27 | OT - Development question |