appending value returned from query
I am trying to return all data of exp_matrix_data.col_id_1
select col_id_
(select col_id from exp_matrix_cols
left join exp_channel_fields on exp_matrix_cols.field_id = exp_channel_fields.field_id
where exp_channel_fields.field_name = 'transfer_agreement_field'
and exp_matrix_cols.col_name = 'school_name')
from exp_matrix_data
the select within the ( ) returns 1, that retrieves the correct id to be added to col_id_, so I can do:
select col_id_1 from exp_matrix_data
T开发者_如何学Gohis does not work, but will give you an idea of what I am trying to accomplish.
You need to use a dynamic query, read this: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
精彩评论