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 generate MySQL query statements in batch with concat

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly introduces "how to use concat to generate MySQL query statements in batches". In daily operation, I believe many people have doubts about how to use concat to generate MySQL query statements in batches. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to use concat to generate MySQL query statements in batches". Next, please follow the editor to study!

Demand background:

A library has 2 users, such as gsgz and gxsnerp.

Gsgz users have all the permissions of this library, while gxsnerp users only have partial table permissions, so you can't use grant all on directly. This statement to give permission, a slightly faster way is to batch generate spliced SQL statements.

Select concat ('grant all on', table_schema, ".", table_name, "to 'gxsnerp'@'localhost';") from tables where table_schema='gxsnerp' and table_name like 'ACT%'

Generate the stitching statement as follows:

Grant all on gxsnerp.ACT_HI_ VARINST` to 'gxsnerp'@'localhost'; grant all on gxsnerp.ACT_GE_PROPERTY to' gxsnerp'@'localhost'; grant all on gxsnerp.ACT_ID_MEMBERSHIP to 'gxsnerp'@'localhost'; grant all on gxsnerp.ACT_HI_ACTINST to' gxsnerp'@'localhost';, the study on "how to use concat to generate MySQL query statements in batches" is over. I hope you can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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