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.
| Author |
Topic |
|
kapilp
Starting Member
2 Posts |
Posted - 2006-01-13 : 00:53:43
|
| hi,i have a table called MapValues with the following columns.MapCategoryMapKeyMapValuethis table is used to store name\value pairs for various dempgraphics. i.e. gender would have one rec with 1, 1, Male and another for 1, 2, Female where the first one is the forgein key to the map categories table and the second one is the key.and the other table is MapCategories which stores the different categories of the name value pairs such as gender and accountTypethis allows me to store multiple name values in just 2 tables instead of have a gender type table and a accounttype table etc..the problem comes in when i want to do a select on lets say the users table.likeselect users.firstname, users.lastname, mapValues.mapValue as gender, mapvalues.mapvalue as accountTypefrom etc...how do i get information from the mapValues table in 2 different columns in one select statement.any ideas? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-13 : 01:05:02
|
use table aliasselect u.*, t1.*, t2.*from users u inner join mapValues t1 on t1.pk = u.pkinner join mapValues t2 on t2.pk = .....where ... -----------------'KH'if you can't beat them, have someone else to beat them |
 |
|
|
kapilp
Starting Member
2 Posts |
Posted - 2006-01-13 : 01:37:36
|
| oh yeah, alias...forgot all about it..thanks. |
 |
|
|
|
|
|
|
|