I have a query which I have tested already and it works fine as just standard MYSQL, but I keep getting the ER_PARSE_ERROR when I implement it within node like so:
function InsertPresenceVal(pval, status) {
connection.query({
sql : "SELECT count(*)INTO @exist FROM information_schema.columns\
WHERE table_schema = database()\
and COLUMN_NAME = 'presence'\
AND table_name = 'userman_users';\
set @query = IF(@exist <= 0, 'alter table userman_users add column presence varchar(20) NULL after username', 'select \'Column Exists\' status');\
prepare stmt from @query;\
EXECUTE stmt;",
timeout : 40000
});
}
I am not sure why and am not sure how to resolve the issue, it seems to have an issue with this line: set @query = IF(@exist <= 0, 'alter table userman_users add column presence varchar(20) NULL after username', 'select \'Column Exists\' status');\
I think its an issue with \
but ave no joy resolving the issue, the query itself is to simply insert a field into the table if it does not exist.
Any suggestions or advice to resolve the issue?