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;
精彩评论