<small id='Ar1H4'></small><noframes id='Ar1H4'>

      <i id='Ar1H4'><tr id='Ar1H4'><dt id='Ar1H4'><q id='Ar1H4'><span id='Ar1H4'><b id='Ar1H4'><form id='Ar1H4'><ins id='Ar1H4'></ins><ul id='Ar1H4'></ul><sub id='Ar1H4'></sub></form><legend id='Ar1H4'></legend><bdo id='Ar1H4'><pre id='Ar1H4'><center id='Ar1H4'></center></pre></bdo></b><th id='Ar1H4'></th></span></q></dt></tr></i><div id='Ar1H4'><tfoot id='Ar1H4'></tfoot><dl id='Ar1H4'><fieldset id='Ar1H4'></fieldset></dl></div>
        <bdo id='Ar1H4'></bdo><ul id='Ar1H4'></ul>

        <legend id='Ar1H4'><style id='Ar1H4'><dir id='Ar1H4'><q id='Ar1H4'></q></dir></style></legend>
      1. <tfoot id='Ar1H4'></tfoot>

        如何将多列组合为一并使用自定义字符串格式化?

        How to combine multiple columns as one and format with custom strings?(如何将多列组合为一并使用自定义字符串格式化?)
          • <bdo id='MUwSL'></bdo><ul id='MUwSL'></ul>

          • <legend id='MUwSL'><style id='MUwSL'><dir id='MUwSL'><q id='MUwSL'></q></dir></style></legend>

                <i id='MUwSL'><tr id='MUwSL'><dt id='MUwSL'><q id='MUwSL'><span id='MUwSL'><b id='MUwSL'><form id='MUwSL'><ins id='MUwSL'></ins><ul id='MUwSL'></ul><sub id='MUwSL'></sub></form><legend id='MUwSL'></legend><bdo id='MUwSL'><pre id='MUwSL'><center id='MUwSL'></center></pre></bdo></b><th id='MUwSL'></th></span></q></dt></tr></i><div id='MUwSL'><tfoot id='MUwSL'></tfoot><dl id='MUwSL'><fieldset id='MUwSL'></fieldset></dl></div>
                <tfoot id='MUwSL'></tfoot>

                    <tbody id='MUwSL'></tbody>

                  <small id='MUwSL'></small><noframes id='MUwSL'>

                  本文介绍了如何将多列组合为一并使用自定义字符串格式化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  SELECT id, <X> AS name FROM `table`
                  

                  基本上
                  的组合姓氏 + ', ' + 名字

                  Basically <X> is a combination of
                  lastname + ', ' + firstname

                  例子是

                     id | name        |
                     2  | Smith, Bob  |
                     3  | Jones, Susy |
                  

                  这只是一个例子,我真的不想把名字组合得这么简单.

                  This is just an example, I don't really want to combine names so simple.

                  推荐答案

                  CONCAT() 函数?

                  SELECT id, CONCAT(lastname, ', ', firstname) AS name FROM `table`;
                  

                  如果要连接多个字段,还可以考虑 CONCAT_WS() 函数,其中第一个参数是其余参数的分隔符,添加在要连接的字符串之间:

                  If you are going to concatenate many fields, you could also consider the CONCAT_WS() function, where the first argument is the separator for the rest of the arguments, which is added between the strings to be concatenated:

                  SELECT id, 
                         CONCAT_WS(',', field_1, field_2, field_3, field_4) list
                  FROM   `table`;
                  

                  这篇关于如何将多列组合为一并使用自定义字符串格式化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Set the variable result, from query(设置变量结果,来自查询)
                  What is dynamic SQL?(什么是动态 SQL?)
                  Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                  Does MySQL have time-based triggers?(MySQL 有基于时间的触发器吗?)
                  is it possible to call a sql script from a stored procedure in another sql script?(是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?)
                  Procedure to loop through comma separated string is not working(遍历逗号分隔字符串的过程不起作用)
                  • <legend id='MfmEu'><style id='MfmEu'><dir id='MfmEu'><q id='MfmEu'></q></dir></style></legend>
                    <i id='MfmEu'><tr id='MfmEu'><dt id='MfmEu'><q id='MfmEu'><span id='MfmEu'><b id='MfmEu'><form id='MfmEu'><ins id='MfmEu'></ins><ul id='MfmEu'></ul><sub id='MfmEu'></sub></form><legend id='MfmEu'></legend><bdo id='MfmEu'><pre id='MfmEu'><center id='MfmEu'></center></pre></bdo></b><th id='MfmEu'></th></span></q></dt></tr></i><div id='MfmEu'><tfoot id='MfmEu'></tfoot><dl id='MfmEu'><fieldset id='MfmEu'></fieldset></dl></div>

                    <small id='MfmEu'></small><noframes id='MfmEu'>

                          <tbody id='MfmEu'></tbody>
                        <tfoot id='MfmEu'></tfoot>

                          • <bdo id='MfmEu'></bdo><ul id='MfmEu'></ul>