Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Converting Master - Child values

Author  Topic 

JustStrolling
Starting Member

15 Posts

Posted - 2006-10-23 : 04:24:59
In Access when you have a ‘LookUp’ column in a table, it literally shows the actual value from the other table instead of the primary key value of that particular table.

Similar to a CBO, where you assign your DisplayMember value and ValueMember value… this is being used in a DataGridView from a dataset(s) in this particular case. The ValueMember (primary key) of the other table is inserted into the column of your current table

I need to compare two fields of similar SELECT statements using a UNION statement; but first I need to convert the value of the one field that holds the primary key value to the ‘DisplayMember’ value so I can later compare by or sort by a valid number or simply not the primary key values of Table2.

Select Table1.Table1Id, Table1.Column1

Table1.Column1 value is the primary key value chosen off of Table2, Table2ID.

Table2
Table2ID
NumberScale

How do I so this?


*Thanks*

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-23 : 04:51:13
Use INNER JOIN.

SELECT Table1.Table1Id, Table2.NumberScale
FROM Table1
INNER JOIN Table2 ON Table2.Table2ID = Table1.Column1


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -