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 implement comparison Operation in mysql

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

Share

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

This article will explain in detail how to implement the comparison operation in mysql. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

MySQL makes numerical comparisons according to the following rules:

If one or two parameters are NULL, the result of the comparison operation is NULL unless an operator such as NULL-safe.

If both parameters in the same comparison operation are strings, the comparison is made according to the string.

If both parameters are integers, they are compared according to integers.

Hexadecimal values are treated as binary strings when they do not need to be compared as numbers.

If one of the parameters is a TIMESTAMP or DATETIME column and the other parameters are constant, the constant is converted to timestamp before comparing. The purpose of this is to make the ODBC proceed more smoothly. Note that this is not suitable for the parameters in IN ()! To be more reliable, the full datetime/date/time string is usually used for comparison.

In other cases, parameters are compared as floating-point numbers.

By default, strings are case-insensitive and use an existing character set (default is cp1252 Latin1, which is also appropriate for English).

For comparison purposes, you can use the CAST () function to convert a value to another type. Use CONVERT () to convert string values to a different character set. See.

The following example illustrates the process of converting a string to a number in a comparison operation:

Mysql > SELECT 1 > 6x

-> 0

Mysql > SELECT 7 > 6x

-> 1

Mysql > SELECT 0 > x6

-> 0

Mysql > SELECT 0 = x6

-> 1

This can indeed lead to security problems if you do not pay attention to it, such as the column in menzhi007. If the character variable query does not have quotation marks, but some functions are filtered and cannot be injected directly, then you can directly submit 0 and bypass it.

This is the end of the article on "how to compare mysql". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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