Re: Obtaining two rows from two different columns in same table
From: Lew Pitcher <lew.pitcher_at_digitalfreehold.ca>
Date: Wed, 29 Apr 2015 12:25:28 -0400
Message-ID: <ZB70x.312495$pp5.289611_at_fx29.iad>
>> How i can get this?
Date: Wed, 29 Apr 2015 12:25:28 -0400
Message-ID: <ZB70x.312495$pp5.289611_at_fx29.iad>
On Wednesday April 29 2015 12:21, in comp.databases.mysql, "Lew Pitcher"
<lew.pitcher_at_digitalfreehold.ca> wrote:
> On Wednesday April 29 2015 11:20, in comp.databases.mysql, "MacMax"
> <macmax_at_nospam.it> wrote:
>
>> Someone can help me?
>>
>> In one table (rel) i have this structure.
>> All three fields are numeric.
>>
>> id, co1, co2
>>
>> In another table (users) i have the names...
>> id_co, name
>> id_co, name
>> etc.
>>
>> I would like this result:
>>
>> id, name (co1)
>> id, name (co2)
> > How are the two tables related? For that matter, how are the two tables > defined? Your DDL (SQL that defines the tables - Data Definition Language) > would be of help here. >
>> How i can get this?
> > Typically, through a table join. But, it depends on how your tables are > defined, specifically with regards to (foreign) keys.
I should note that the table join would give you the <<id, name>> part of the resultset.
OTOH, a UNION will give you the <<id, co1 / id, co2>> part.
> > Show us your table definitions, and we can help with the query SQL. >
-- Lew Pitcher "In Skills, We Trust" PGP public key available upon requestReceived on Wed Apr 29 2015 - 18:25:28 CEST