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 use quotation marks written by dynamic statements in mysql

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

Share

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

This article mainly shows you the "mysql dynamic statements written in quotation marks how to use", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "mysql dynamic statements written in quotation marks how to use" this article.

When we write the dynamic SQL of MYSQL stored procedures, we often write the SQL prototype first, and then write it in a dynamic form according to our needs.

But often this process is very painful, because you can deal with a lot of single quotes and some special characters.

When we write the dynamic SQL of MYSQL stored procedures, we often write the SQL prototype first, and then write it in a dynamic form according to our needs.

But often this process is very painful, because you can deal with a lot of single quotes and some special characters. If you have written about ORACLE PL/SQL, you will have the experience of meeting.

Fortunately, however, double quotation marks are supported in MYSQL. That is to say, if you basically don't change the SQL prototype, MYSQL will move here as is.

For example, the SQL prototype we want is as follows:

Select * from mysql.user where user='root' limit 10

If written as dynamic SQL:

Set @ sql = "select user,host from mysql.user where user='root'"

Set @ sql = concat (@ sql, "

Limit 10 ")

Prepare sql1 from @ sql

Execute sql1

Deallocate PREPARE sql1

The above is all the contents of the article "how to use quotation marks in dynamic statements in mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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