I have a database table structure as follow:
datatype
data
mytable
now datatype has primary key datatypeid, data table has datatypeid as foriegn key and has mytable id as foreign key.
In datatype I have a column called description which has address1, address2 etc
And the values for these addresses are stored in data table using the datatypeid as reference.
So I want to make a select statement to show the ids from mytable and address1, address2 etc as columns, with the values coming from data.values as follow:
id address1 address2
1 test add test add2
2 test add test add2
2 test add test add2
here is my query so far but it outputs it in different format:
SELECT id
FROM datatype
INNER JOIN data ON datatype.DataTypeID = data.DataTypeID
INNER JOIN mytable ON data.ID = mytable.ID
EDIT :
table structure:
datatype
-datatypeid int
-description varchar(50)
data
-id int
-datatypeid int
-datavalue varchar(50)
-mytableid int
mytable
-mytableid int
-datecreated datetime
Sample Data
datatype :
datatypeid description
1 address1
2 address2
data :
id datatypeid datavalue mytableid
1 1 george street 1
mytable:
mytableid datecreated
1 2012-02-17 10:06:02.507
Can you help please?
spitballing this, but give it a try