Home  >  Article  >  Database  >  What is the difference between # and $ in sql

What is the difference between # and $ in sql

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-05-10 09:07:224418browse

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete