Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Two fields
Message
 
 
To
27/04/2005 04:14:20
Maltin Lacsina
Angeles Electric Corporation
Angeles, Philippines
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Miscellaneous
Thread ID:
01008746
Message ID:
01008778
Views:
17
SELECT t1.field1, t21.Description AS Description1, 
       t1.field2, t22.Description AS Description2 
  FROM table1 t1
    JOIN table2 t21 ON t21.code = t1.field1
    JOIN table2 t22 ON t22.code = t1.field2
>The problem is I have a table that need the description of the other table with two fields:
>
>Table 1 with field
> Field1
> Field2
>
>Table 2 with field
> Code
> Description
>
>
>Ex:
>  The table 1 has a record
>      Field1    Field2
>      '001'     '004'
>      '002'     '001'
>
>  The table 2 has a record
>      Code   Description
>      '001'  'Sample 1'
>      '002'  'Sample 2'
>      '003'  'Sample 3'
>      '004'  'Sample 4'
>
>  I need to get a SQL statement like this:
>      Field1Code Field1Description Field2Code Field2Description
>      '001'      'Sample 1'        '004'      'Sample 4'
>      '002'      'Sample 2'        '001'      'Sample 1'
>
>I hope someone can help me with this.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform