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 |
|
knudmt
Starting Member
12 Posts |
Posted - 2011-05-04 : 21:31:44
|
| So still a noob :( And I am having a hard time performing a proper join on these tables. Could someone shed some light on this?Thanks!here is my db schemaFileTblguidId int PKAttributes Tableid PKguidId FK ref FileTble(guidid)name varcharAttributeValues tableattId int FK ref Attributes(id)setValueId int FK ref setvalue(id)exactValue bitguidId int FK FileTbl(guidId)setvalueid int PK value varcharExample of how these tables might look:FileTbl145267Attributes1, 145, language2, 145, length3, 267, languageAttributeValues1, 10, false, 1452, 11, false, 1453, 23, false, 145SetValue10, en-us11, long23, en-caSo I would like a query that would give me the following values:The Attributes.name and SetValue.value for a given FileTbl.guidId ie. return a table showing ALL the Attributes.name and SetValue.value for a single FileTbl.guidIdIf someone could be so kind to give me an example of how this would be done and I would be super excited if you could explain your logic :)I'm in a bit of a tight spot your help would be greatly appreciated!Thanks! |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-05-04 : 22:09:25
|
EAV model! Many people on this forum would warn you about the pitfalls and predicaments you may get into with that. But, I am not here to lecture you (although it is very tempting ), so see if this works for you:select at.name, sv.valuefrom attributes at inner join attributevalues av on av.attId = at.id inner join SetValue sv on sv.id = av.SetValueId |
 |
|
|
knudmt
Starting Member
12 Posts |
Posted - 2011-05-04 : 22:18:59
|
| please feel free to lecture!!! If you can poke holes in the schema feel free. :) not just looking for answers but insight :)Thanks again sunitabeck when I get around my dev machine I will try this out |
 |
|
|
|
|
|
|
|