mysql - How to put single quotes around variables in a dynamic query -



mysql - How to put single quotes around variables in a dynamic query -

i trying build dynamic query. @query set query string , want dynamically add together clause. works, except isn't putting single quotes around strings in case @val. causes error. how include single quotes adds them correctly?

this i've tried:

set @query = @query + ' ' + '' + @param + ' ' + @operator + ' ' + '' + @val + '' ;

thanks!

you have place quote in between quotes, escape doesn't break code. following:

set @query = @query + ' ' + '' + @param + ' ' + @operator + ' ' + '\'' + @val + '\'' ;

edit: eric anderson's reply works well. take mysql 5.0 manual

a “'” within string quoted “'” may written “''”.

mysql dynamic-sql

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -