Below I have the SQL query which I have tested is working fine
Select
data_info.user_id, data_info.type_id, data_info.specific_title,
data_info.content, life_area.type_id, life_area.type_id
From
data_info
Left Join
life_area On data_info.type_id = life_area.id
Where
data_info.user_id = '0001'
Now I am trying to convert the working SQL into asp.net MySqlCommand, but it fails to work and show syntax error
MySqlCommand cmd = new MySqlCommand(
"Select data_info.user_id,data_info.type_id,data_info.specific_title,data_info.content,"+
"life_area.type_id,life_area.type_id" +
"FROM data_info LEFT JOIN life_area ON data_info.type_id = life_area.id" +
"Where data_info.user_id='0001'" , conn);
... area.type_id" (space?) + "FROM ...FROMfor starters. I'd suggest creating a verbatim string instead (put a '@' before it) so you can include line breaks instead of the concatenation mess you currently have. Also in the future you really should include the error message you get.@before the string it allows it to span multiple lines and it is called a verbatim string Also you got an error message when you tried to run this code, you should always include error messages in questions.