简体   繁体   中英

MYSQL syntax error in CONVERT function

I have some problem in MYSQL syntax

This statement is work correctly

CONVERT(_latin1 'SOME-AR-TEXT' USING utf8));

But i don't need the 'SOME-AR-TEXT' value, i need the value of some variable.

In other words, i tried to do this

CONVERT(_latin1 (SELECT some_variable) USING utf8));

But the console display syntax error.

What can i do to get the value of some_variable variable.

Thank you all

SELECT CONVERT(some_variable USING UTF8) AS field_value
  FROM MyTable

By your SQL fiddle it seems like you want to convert each field. Why not just create the table with default charset latin? In that way, you would not have to specifially convert each field.

CREATE TABLE IF NOT EXISTS `example` (
  `some_variable` varchar(30) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

And there is something wrong the terminology as well. 'some_variable" isn't really a variable but a column/field in the database-table example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM