I am new in MySQL. I am not sure that i am right thing. Need help.
I have a table survey
which have the following column:
id, source_type, source_id, survey_date_time
.
Other two tables are:
education
which have id, col1, col2, col3
columns.
games
which have id, col4, col5, col6
columns.
Data in survey
table:
id source_type source_id survey_date_time
--------------------------------------------------------
100 education 1 2013-07-25 00:00:00
101 games 1 2013-07-25 00:00:00
102 games 2 2013-07-26 00:00:00
103 education 2 2013-07-26 00:00:00
Data in education
table
id col1 col2 col3
--------------------------------------------
1 col1_data1 col2_data1 col3_data1
2 col1_data2 col2_data2 col3_data2
Data in games
table
id col4 col5 col6
--------------------------------------------
1 col4_data1 col5_data1 col6_data1
2 col4_data2 col5_data2 col6_data2
I want to read data dynamically like:
select * from survey left join {survey.sorce_type} on {survey.sorce_type}.id=survey.source_id where survey.id={given_id}
You can find the the schema here
Thanks in advance.
UPDATE :
select statement will be survey.*, {survey.sorce_type}.*
instead of *
Thanks