• <legend id='6DYsY'><style id='6DYsY'><dir id='6DYsY'><q id='6DYsY'></q></dir></style></legend>
  • <tfoot id='6DYsY'></tfoot>

    • <bdo id='6DYsY'></bdo><ul id='6DYsY'></ul>

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

        <small id='6DYsY'></small><noframes id='6DYsY'>

        MySQL 合并两列并添加到一个新列中

        MySQL combine two columns and add into a new column(MySQL 合并两列并添加到一个新列中)

          <bdo id='G22yK'></bdo><ul id='G22yK'></ul>

          1. <legend id='G22yK'><style id='G22yK'><dir id='G22yK'><q id='G22yK'></q></dir></style></legend>
            <i id='G22yK'><tr id='G22yK'><dt id='G22yK'><q id='G22yK'><span id='G22yK'><b id='G22yK'><form id='G22yK'><ins id='G22yK'></ins><ul id='G22yK'></ul><sub id='G22yK'></sub></form><legend id='G22yK'></legend><bdo id='G22yK'><pre id='G22yK'><center id='G22yK'></center></pre></bdo></b><th id='G22yK'></th></span></q></dt></tr></i><div id='G22yK'><tfoot id='G22yK'></tfoot><dl id='G22yK'><fieldset id='G22yK'></fieldset></dl></div>
          2. <small id='G22yK'></small><noframes id='G22yK'>

                <tbody id='G22yK'></tbody>
                <tfoot id='G22yK'></tfoot>
                • 本文介绍了MySQL 合并两列并添加到一个新列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我的 MySQL 表具有以下结构:

                  I have the following structure with a MySQL table:

                  +----------------+----------------+----------+
                  |    zipcode     |      city      |   state  |
                  +----------------+----------------+----------+
                  |     10954      |     Nanuet     |    NY    |
                  +----------------+----------------+----------+
                  

                  我想将上述 3 列合并为一列,如下所示:

                  I want to combine the above 3 columns into one column like this:

                  +---------------------+
                  |      combined       |
                  +---------------------+
                  | 10954 - Nanuet, NY  |
                  +---------------------+
                  

                  并且我想在不破坏原始 3 个字段的情况下将此组合"列添加到表的末尾.

                  And I want to add this "combined" column to the end of the table without destroying the original 3 fields.

                  推荐答案

                  创建列:

                  ALTER TABLE yourtable ADD COLUMN combined VARCHAR(50);
                  

                  更新当前值:

                  UPDATE yourtable SET combined = CONCAT(zipcode, ' - ', city, ', ', state);
                  

                  自动更新所有未来值:

                  CREATE TRIGGER insert_trigger
                  BEFORE INSERT ON yourtable
                  FOR EACH ROW
                  SET new.combined = CONCAT(new.zipcode, ' - ', new.city, ', ', new.state);
                  
                  CREATE TRIGGER update_trigger
                  BEFORE UPDATE ON yourtable
                  FOR EACH ROW
                  SET new.combined = CONCAT(new.zipcode, ' - ', new.city, ', ', new.state);
                  

                  这篇关于MySQL 合并两列并添加到一个新列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                    • <bdo id='HyN4b'></bdo><ul id='HyN4b'></ul>
                      <legend id='HyN4b'><style id='HyN4b'><dir id='HyN4b'><q id='HyN4b'></q></dir></style></legend>
                        <tbody id='HyN4b'></tbody>

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

                        <tfoot id='HyN4b'></tfoot>

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