0

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

1
  • What is in @rowname_date? Please post the result of SELECT @rowname_date;
    – peterm
    Commented Oct 15, 2013 at 7:53

1 Answer 1

1

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

1
  • @Gordon Did it help? Do you need more help with your question?
    – peterm
    Commented Oct 16, 2013 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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