Home > Database > Mysql Tutorial > body text

What is the difference between # and $ in sql

醉折花枝作酒筹
Release: 2021-05-10 09:07:22
forward
4410 people have browsed it

This article will introduce to you the difference between # and $ in sql. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

What is the difference between # and $ in sql

#{} is used here. When using #:

1. Used to pass in parameters. SQL will add " ", parsed as a string, such as here role_id = "roleid";

2, #{} can largely prevent sql injection;

Extension:

1. Use the incoming data to directly display in the generated sql, such as the above statement, use roleid= to directly display the incoming data in the generated sql, such as the above statement, use roleid={roleId, jdbcType=INTEGER}, then the value of sql is roleId = roleId when parsing, and an error will be reported during execution;

2, ${} method cannot prevent sql injection;

3, $ is generally used Input the database object, such as the database table name;

4. Try to use #{} when you can use #{};

Note:

## When using order by dynamic parameters when sorting #mybaties, you need to pay attention to using ${} instead of #{};

Related recommendations: "

mysql tutorial"

The above is the detailed content of What is the difference between # and $ in sql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
sql
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template