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 |
|
baburk
Posting Yak Master
108 Posts |
Posted - 2008-11-19 : 02:50:47
|
| Hi,Here ItemTags.ItemId is having concatenated ItemId like 1,2,3How can I use this in ON clause.I used split function to split the ItemTags.ItemIdFROM dbo.Users INNER JOIN dbo.Items ON Users.UserId = Items.UserId INNER JOIN dbo.ItemTags ON 1 =1 --Items.ItemId = INNER JOIN (SELECT Item FROM dbo.[Split](',', ItemTags.ItemId)) AS T ON Items.ItemId = CAST ( T.Item AS INT)WHERE UserName = 'babu'I am getting this errorThe multi-part identifier "ItemTags.ItemId" could not be bound.Thanks. |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2008-11-19 : 03:29:22
|
| Its not a better idea to have comma seperated values in a column. It violates basic relational db principles. Please post you requirement, table structure and sample data. Someone here will help you out design it better. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-19 : 03:34:01
|
cant use inner join here. use CROSS APPLY insteadFROM dbo.UsersINNER JOIN dbo.ItemsON Users.UserId = Items.UserIdINNER JOIN dbo.ItemTagsON 1 =1 --Items.ItemId = CROSS APPLY (SELECT Item FROM dbo.[Split](',', ItemTags.ItemId)) AS TWHERE Items.ItemId = CAST ( T.Item AS INT)AND UserName = 'babu' |
 |
|
|
|
|
|