Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to dynamically copy data from one table to another according to table data by sql stored procedure

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how sql stored procedures dynamically copy data from one table to the contents of another table based on table data. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

Dynamically copy data from one table to another based on table data

Copy the record of track table to the corresponding track_id according to the last two digits of mac_id. in the table

For example:mac_id=12345678910, then the corresponding table of the last two digits 10 is track_10, copy this record to track_10

Create a sub_track stored procedure implementation:

--Create a stored procedure named sub_track CREATE PROCEDURE sub_track()begin declare i int; --Define loop variable i set @imei =0; --Define last two bits of imei set @t_count=0; --Define how many records the table has Variable SET i=0; SELECT COUNT(*)INTO @t_count FROM track; --Get the number of entries in the table while i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report