sql 如何在Mysql中连接字符串
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 如何在Mysql中连接字符串相关的知识,希望对你有一定的参考价值。
-- CONCAT()
SELECT CONCAT(column_name_or_string,column_name_or_string,...) table_name;
-- https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat
-- Example
SELECT CONCAT(author_fname,' ',author_lname) FROM books;
-- CONCAT_WS()
CONCAT_WS(separator,column_name_or_string,column_name_or_string)
-- https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat-ws
-- Examples
SELECT CONCAT_WS(' ',author_fname,author_lname, '25 years old') FROM books;
SELECT CONCAT_WS('-',author_fname,author_lname, '25 years old') FROM books;
以上是关于sql 如何在Mysql中连接字符串的主要内容,如果未能解决你的问题,请参考以下文章