how about a double left join.  pick your base 
table, and then pick your request table twice, 
with each request table left joined to the base 
table and each returning its appropriate field.

maybe?

look in the portals for a tool that makes the 
outlandish claim of querying any data source ever 
made.  you can use it to quickly try out little 
query tricks.  i just tried this one and it seems 
to work.  since my mysql server didn't have a 
database suitable for it, i ran it against ms sql 
and oracle and it worked.

(i can't name it here because i'll get in trouble 
again.)



> 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
> 
> 
> 



-- 
        John Ragan
        [EMAIL PROTECTED]
        http://www.CoreReader.com/ 


---------------------------------------------------------------------
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