开发者

Output a MySQL formatted string

Suppose I have a query likes:

SELECT name FROM product WHERE id = 28;

The result is 开发者_Go百科"HTC Desire HD"

I want this result to be replaced with XX in the string "I Like XX", after replacing, the string is "I Like HTC Desire HD"

Likes the PHP printf function, can I use MySQL to do that?


That would be:

select 'I Like ' || name from product where id = 28;

in regular SQL. I'm not entirely certain that will work in MySQL unless you have PIPES_AS_CONCAT configured, but the equivalent:

select CONCAT('I Like ', name) from product where id = 28;

should be fine.


Like a CONCAT()?

SELECT CONCAT('I Like ',name)
FROM   product
WHERE  id = 28;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜