开发者

MySQL query result that use value of other fields

开发者 https://www.devze.com 2023-03-16 06:26 出处:网络
I\'m looking for something like format() in开发者_C百科 other programming languages in MySQL query. The expected result is text that has values from other fields.

I'm looking for something like format() in开发者_C百科 other programming languages in MySQL query. The expected result is text that has values from other fields.

For example, something like

select formatted from table where formatted=stringformat('some text {0}, {1} some text.', field1, field2)


how about:

SELECT CONCAT('some text ', field1, ', ', field2, ' some text.') FROM table;


create a column in query and give it any alias to get result in. see this example.


SELECT ('some text, ' + tb.Col1 + ', ' + tb.Col2)    AS    ColName
FROM   MyTable   tb

0

精彩评论

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