Bug #116997 select where 1=? 问题
Submitted: 17 Dec 2024 10:15 Modified: 17 Dec 2024 11:11
Reporter: fanshuo meng Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.36 OS:Any
Assigned to: CPU Architecture:Any
Tags: SELECT

[17 Dec 2024 10:15] fanshuo meng
Description:
SELECT * FROM your_table WHERE 1='1agavagag'

This sql can query data.

How to repeat:

Where 1='1 random string no number'
[17 Dec 2024 11:11] MySQL Verification Team
Hi Mr. meng,

Thank you for your bug report.

However, this is not a bug.

Your query:

SELECT * FROM your_table WHERE 1='1agavagag'

returns data, because when you compare an integer to a string, MySQL uses floating point number as a common denominator.

As 1 is always equal to 1, you will get a result set. Hence , this is expected behaviour.

But if you look at the warning, that this query returns, you will see why are results returned:

mysql> show warnings;
+---------+------+-----------------------------------------------+
| Level   | Code | Message                                       |
+---------+------+-----------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: '1agavagag' |
+---------+------+-----------------------------------------------+
1 row in set (0.00 sec)

Not a bug.