linking rows

2006-02-23 Thread Tim Johnson
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 [EMAIL PROTECTED]
  http://www.alaska-internet-solutions.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: linking rows

2006-02-23 Thread SGreen
Tim Johnson [EMAIL PROTECTED] 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 [EMAIL PROTECTED]
   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/articles/intro-to-normalization.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



Re: linking rows

2006-02-23 Thread Tim Johnson
* [EMAIL PROTECTED] [EMAIL PROTECTED] [060223 09:09]:
 Tim Johnson [EMAIL PROTECTED] wrote on 02/23/2006 12:26:35 PM:
  I need the most efficient way to do this: examples, keywords, and
  URLs to relevant documentation are all welcome.
 
 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/articles/intro-to-normalization.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 [EMAIL PROTECTED]
  http://www.alaska-internet-solutions.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]