Jump to content


Photo

Mysql querry problem


  • Please log in to reply
2 replies to this topic

#1 grinel

grinel
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 April 2006 - 06:58 PM

Hey guys

I need a help with a query

I have 2 tables

table 1
code,description


table 2
field,field2,code1,code2, field3, etc

code1,code2 in table 2, their descriptions can be found in table 1.

i want a query to show me all the records in table 2, but with the codes description instead of the code itself

The result set must therefore have 2 fields for desription, because code1 will not equal code 2
I am stuck with mysql 3.23....

Thanks in advance

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 14 April 2006 - 08:25 PM

SELECT a.field1, a.field2, b.description as descr1, c.description as descr2, a.field3, a.etc FROM table2 a LEFT JOIN table1 b ON b.code=a.code1 LEFT JOIN table1 c ON c.code=a.code2


#3 grinel

grinel
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 April 2006 - 12:35 PM

Hey
Thanks alot

I really appreciate it.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users