是否可以将文本添加到SQL select语句中。 e.g:
var query = "SELECT id, " +
"picture "
"FROM people";
到
var query = "SELECT id, " +
"picture AS './directory/' + picture "
"FROM people";
答案 0 :(得分:0)
是。像这样:
var query = "SELECT id, " +
"concat('./directory/',picture) AS picture "
"FROM people";
更多细节:http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat
答案 1 :(得分:0)
您正在将查询构造为字符串,所以是的,您可以这样做。但是,您必须将值作为常量插入。类似的东西:
var query = "SELECT id, " +
"picture AS " + directory " + "picture "
"FROM people";
但是,directory
需要是应用程序中的值而不是数据库(尽管另一个语句可以读取它)。