Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

set @sqlt = concat("select", @rowname_date," from syslog_data.syslogs_index_1 "); prepare stmt from @sqlt; execute stmt; deallocate prepare stmt;

gives me a eeror 1064 in the prepare statement? Any advise please. Thanks

share|improve this question
What is in @rowname_date? Please post the result of SELECT @rowname_date; – peterm Oct 15 '13 at 7:53

Assuming that you have a valid column name or a properly escaped literal in @rowname_date and you don't have leading spaces in it then you have to have a space after SELECT clause

set @sqlt = concat("select", @rowname_date," from syslog_data.syslogs_index_1 ");

Here is SQLFiddle demo

share|improve this answer
@Gordon Did it help? Do you need more help with your question? – peterm Oct 16 '13 at 8:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.