Re: MySQL query question
Posted by:
Reeju Vava
Date: March 14, 2009 04:23AM
lan w Wrote:
-------------------------------------------------------
> Hi,
>
> I have two tables, the sample structure and data
> of table A is:
> id, awardname1,awardname2,awardname3
> 1 abc def ghi
>
> the sample structure and data of table B is:
> awardname awardcode
> abc x1
> def x2
> ghi x3
>
> Is there a query I can use to get the awardcode
> for each row in table A?
> the result like:
> id, awardname1, awardcode1, awardname2,
> awardcode2, awardname3, awardcode3
> 1 abc x1 def x2
> ghi x3
>
> Any help will be appreciated!
> Lan
select a.id,a.awardname1,b.awardcode,a.awardname2,c.awardcode,a.awardname3,d.awardcode from tableA a,tableB b,tableB c,tableB d where a.awardname1=b.awardname and a.awardname2=c.awardname and a.awardname3=d.awardname;