At 18:22 -0600 11/1/02, John Ragan wrote:
>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.)
C'mon now. The objections were just to plugging yer
tool without making any attempt to actually answer
the questions that were being asked.
Above, you're answering the question. Not a problem.
>
>
>
>> 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