如何从表中的某个列复制多条记录并插入以使用 SQL 命令在 mysql 中使用不同选项更新列中的另一个表
列:“targetCategory”条件所有记录包含Top/name_test2、Top/name_test2/%
列“标题”,“父主题参考数据注意:数据有根不同,不导入示例:Top/name_test752
table_exemple1
===========================================================================
| aliasID | title | targetCategory | parentTopic |
===========================================================================
No | 1 | name_test752 | Top/name_test752/tel | Top/name_test752 |
---------------------------------------------------------------------------
|-<----| 2 | name_test2 | Top/name_test2 | Top/name_test2 |
| ---------------------------------------------------------------------------
||-<---| 3 | 5 | Top/name_test2/etc/5 | Top/name_test2/etc|
|| ---------------------------------------------------------------------------
|||-<--| 4 | tesla | Top/name_test2/tesla | Top/name_test2 |
||| ----------------------------------------------------------------------------
|||
|||
||| **tabla_exemple2 before update**
||| =====================================================================================================================================================================
||| | id | topic | topicShort | parentTopic | displayName | description | lastUpdate | sitecount |
||| =====================================================================================================================================================================
||| | 1 | Top/name_test/helloo | helloo | Top/name_test752 | Nuul | hello | 2010-06-19 04:10:14 | 324 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 2 | Top/name_test2/nest | nest | Top/name_test2/ | Nuul | nest | 2010-06-19 04:11:23 | 545435 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 3 | Top/name_test2/etc/57 | 5 | Top/name_test2/etc/ | Nuul | 5 | 2010-06-19 04:15:13 | 54354343 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 4 | Top/name_test2/tesla1 | tesla | Top/name_test2/ | Nuul | tesla | 2010-06-19 04:10:14 | 676756 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|||
|||
||| **table_exemple2** after update
|||
|||
||| =====================================================================================================================================================================
||| | id | topic | topicShort | parentTopic | displayName | description | lastUpdate | sitecount |
||| =====================================================================================================================================================================
||| | 1 | Top/name_test/helloo | helloo | Top/name_test752 | Nuul | hello | 2010-06-19 04:10:14 | 324 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 2 | Top/name_test2/nest | nest | Top/name_test2/ | Nuul | nest | 2010-06-19 04:11:23 | 545435 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 3 | Top/name_test2/etc/57 | 5 | Top/name_test2/etc/ | Nuul | 5 | 2010-06-19 04:15:13 | 54354343 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
||| | 4 | Top/name_test2/tesla1 | tesla | Top/name_test2/ | Nuul | tesla | 2010-06-19 04:10:14 | 676756 |
||| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|||--->| 6 | Top/name_test2 | name_test2 | Top | Nuul | name_test2 | insert data | 0 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|----->| 7 | Top/name_test2/etc/5 | 5 | Top/name_test2/etc | Nuul | 5 | insert data | 0 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|----->| 8 | Top/name_test2/tesla | tesla | Top/name_test2 | Nuul | tesla | insert data | 0 |
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Data from "targetCategory" wil goo to "topic"
data from "title" goo to "topicShort"
Data from "parentTopic" goo to "parentTopic"
I ned insert new data to column "displayName" well be "Nuul"
I ned insert new data to column "description" well be idem "topicShort"
I ned insert new data to column "displayName" well be "Nuul"
I ned insert new data to column "lastUpdate" well be "data time inserition"
I ned insert new data to column "displayName" well be "0"
condition its column targetCategory data like Top/name_test2 and like Top/name_test2/%