Jeff,

Try a JOIN:

http://www.mysql.com/doc/en/JOIN.html

or for some good articles:

http://www.onlamp.com/pub/ct/19

HTH!

Cory


On Fri, 2002-11-01 at 10:01, jeff wrote:
> Hello....
> 
> I am having some trouble writing a query that will pull the information I
> need from the database. I hope it's even possible at this point.
> 
> A little background -
> 
> I have one table called 'request' and another table 'countries'
> The request form we have has three seperate address groups in it, so it
> takes three different countries per entry. The countries table contains
> 'country_id' and 'country_name'. The 'request' table contains 'x_country',
> 'y_country' and 'z_country' - these fields all reference the 'country_id'
> field in the 'countries' database.
> 
> Now for the delimma -
> 
> I need to pull out some information and dump it to a spreadsheet. That's
> no problem, but I need the country names instead of the country_id.
> 
> So if I do - SELECT x_country, y_country, z_country FROM request WHERE ID
> = x - I'll get the following:
> 
> -------------------
> | 154 | 153 | 154 |
> -------------------
> 
> instead, I need this:
> 
> --------------------------------------------------
> | United States | United Kingdom | United States |
> --------------------------------------------------
> 
> I can dump one country by doing:
> 
> SELECT x_country, country_name FROM request, countries WHERE x_country =
> country_id AND ID = x
> 
> But I was hoping I would be able to do all three in one query.
> Any help would be *greatly* appreciated!
> 
> Thanks!!!
> 
> jeff
> 
> 
> 
> ---------------------------------------------------------------------
> 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 <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 



---------------------------------------------------------------------
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 <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to