should be simple enough but it’s causing me a couple of issues.
I have a data set similar to the following:
User UserID Name Age UserPropertyValues UserID PropertyCodeValueID PropertyCodes PropertyCodeID PropertyCodeName PropertyCodeValues PropertyCodeValueID PropertyCodeID PropertValue
Now let’s assume the tables contain the following data:
1 John 25 2 Sarah 34 1 2 1 3 2 1 2 3 1 FavColour 2 CarMake 3 PhoneType 1 1 Blue 2 1 Yellow 3 2 Ford 4 3 Mobile 5 3 Landline
Now from this I’m looking to create a view to return the User details, as well as the property values for Property code 1 and 2 like so:
John 25 Yellow Ford Sarah 34 Blue Ford
The queries I have tried so far tend to return repeating rows of data :
John 25 Yellow John 25 Ford Sarah 34 Blue Sarah 34 Ford
Any help is appreciated, thank you all in advance.
Input data:
If two properties is all that you need in result, and each user have those properties, then try this:
[edit] But to handle possible NULL values better use this: