标签: java mysql
我的java代码:
StringBuilder stringQuery = new StringBuilder("select product_id, type || '_' || price as info "); SQLQuery q = createSQLQuery(stringQuery.toString()); q.list();
我收到此错误:
Caused by: java.sql.SQLException: Column '' not found.
答案 0 :(得分:2)
||是MySQL中的OR运算符,它不会连接type,'_'和price的值。您可能希望/需要使用CONCAT函数:
||
OR
type
'_'
price
CONCAT
StringBuilder stringQuery = new StringBuilder("select product_id, CONCAT(type, '_', price) as info "); //...