Click here to Skip to main content
15,884,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

We have a tables like This(simplified version):
1- table Properties :
id       PropName      ParentId
1        Properties    null
2        color         1
3        Length        1
4        width         1
5        Area          1


ParentId is Fk To Id in Table Properties

2- Tabl Properties_value :
id       PropName      ParentId  ItemId
1        red             2          1
2        100             3          1


ParentId is Fk To Id in Table Properties &ItemId is Fk To Id in TableItem
3- TableItem :
id       ItemName   ItemNo
1        Tv         100


I Need query a sql that gives the following result/format with high performance
Item_id   ItemName ItemNo   Color  Length        
 1           Tv     100     Red    100


I Tried The pivot Method To Get This Result But The Query Became Very Complex And There Was Alot Of Performance Issues So, what can I do to Get This Result What is your ideas?
Posted
Updated 20-Sep-11 3:17am
v5
Comments
Reiss 20-Sep-11 8:01am    
You have tagged your question as both MS-SQL and MySQL, which one is it as thiscould impact the answer

1 solution

Your design is flawed.

The Item table should have the properties as columns (color, length etc).

This way your queries will be much easier.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900