|
Home > Archive > MySQL ODBC Connector > February 2006 > "linking" rows
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]
|
|
| Tim Johnson 2006-02-25, 9:43 am |
| Let's say I have a query that performs
"select * from Account"
one of the columns from "Account" (city) is actually a key which may
be either numeric or character.
There is a table called "City" which contains keys and names of cities.
and I want the City.Name value where Account.city matches City.ID.
I need the most efficient way to do this: examples, keywords, and
URLs to relevant documentation are all welcome.
thanks
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
| |
| SGreen@unimin.com 2006-02-25, 9:43 am |
| --=_alternative 006139458525711E_=
Content-Type: text/plain; charset="US-ASCII"
Tim Johnson <tim@johnsons-web.com> wrote on 02/23/2006 12:26:35 PM:
> Let's say I have a query that performs
>
> "select * from Account"
>
> one of the columns from "Account" (city) is actually a key which may
> be either numeric or character.
>
> There is a table called "City" which contains keys and names of cities.
>
> and I want the City.Name value where Account.city matches City.ID.
>
> I need the most efficient way to do this: examples, keywords, and
> URLs to relevant documentation are all welcome.
>
> thanks
> tim
>
> --
> Tim Johnson <tim@johnsons-web.com>
> http://www.alaska-internet-solutions.com
>
First off, columns can either be numeric or character-based not both. You
can store arrangements of the characters "0" through "9" in a
character-based field but those are not numbers, they are strings that
look like numbers.
Your description makes it sound like you have a table that has data in a
column called 'city' that looks like:
Atlanta
Boston
15
10
24
Paris
Rome
215
Tokyo
or am I mistaken?
Back to your direct question: How you "link" two tables is called
"joining". There are tons of examples and tutorials of how to join tables.
One of my favorites is
http://sqlzoo.net/
It takes you through everything you need in order to get your feet wet and
it gives you the ability to immediately try out what you are being taught.
If you work through their examples you should be able to make some decent
headway.
I also recommend you read this article about normalization:
http://dev.mysql.com/tech-resources...malization.html
There is a query that can do what you want but I strongly suggest you
review your design before moving too much farther into this project.
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
--=_alternative 006139458525711E_=--
| |
| Tim Johnson 2006-02-25, 9:43 am |
| * SGreen@unimin.com <SGreen@unimin.com> [060223 09:09]:
> Tim Johnson <tim@johnsons-web.com> wrote on 02/23/2006 12:26:35 PM:
<....>[color=darkred]
> First off, columns can either be numeric or character-based not both. You
> can store arrangements of the characters "0" through "9" in a
> character-based field but those are not numbers, they are strings that
> look like numbers.
Of course. Didn't mean to imply other wish.
> Your description makes it sound like you have a table that has data in a
> column called 'city' that looks like:
>
> Atlanta
> Boston
> 15
> 10
> 24
> Paris
> Rome
> 215
> Tokyo
>
> or am I mistaken?
You got it.
> Back to your direct question: How you "link" two tables is called
> "joining". There are tons of examples and tutorials of how to join tables.
> One of my favorites is
Deliberately left out an inquery about "join" to encourage possibly
other suggestions. :-)
> http://sqlzoo.net/
> I also recommend you read this article about normalization:
> http://dev.mysql.com/tech-resources...malization.html
Those are the links that I needed. Getting up to speed on 'join is my
solution...
Thanks
(time to do my homework)
tim
--
Tim Johnson <tim@johnsons-web.com>
http://www.alaska-internet-solutions.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql? unsub...sie.nctu.edu.tw
|
|
|
|
|