Since the US Postal Service has official 2 character codes for each
state, why not use them?
You could use an enum type, or validate against a 1 column state table.
Why complicate every query with a join to as state
table?
Steven Kreuzer wrote:
> Hello All,
>
> First, Let me start by saying this question has most likely been asked
> before, but I did a search in the archive and was unable to come up
> with any results. I think this is because I am not quite sure what
> this is called. So, I do apologize, but hopefully this can be answered
> quickly and will really help me out.
>
> This is more of a General SQL question, regarding sytanx.
>
> I have 3 table I am going to be working on. contact, address and state.
> state contains 51 states (Washington D.C is listed as a state) each
> with their unique ID. Contact contains a persons first and last name,
> as well as their own ID. Address contains their street name, the city,
> state and a column called contactid for the id of the person who lives
> there.
>
> State is a foreign key for the state table and contactid is a foreign
> key for the contact's id.
>
> Now here is what I want to do:
>
> I want to insert a person into the contact database and then insert
> their address into the address table, but I want to somehow put the ID
> of the state, and the id of the contact into the fields without
> actually having to know the values.
>
> Like rather then having to look up New York and then insert 033, can I
> just somehow put "New York"?
>
> Is this possible to do?
>
> Many thanks
> -Steven
>
> mysql, sql, query
>
>
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <mysql-thread116131@stripped>
> To unsubscribe, e-mail
> <mysql-unsubscribe-gerald_clark=suppliersystems.com@stripped>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>
| Thread |
|---|
| • INSERT Question | Steven Kreuzer | 1 Aug |
| • Re: INSERT Question | Gerald Clark | 1 Aug |