Home > Article > Daily Programming > What cannot be represented by % in mysql
In MySQL, % does not represent a decimal. It is a wildcard character that can match any number of any characters, but cannot be used to represent decimals. To match decimals, use the BETWEEN operator or comparison operators such as >= and <=.
In MySQL, what can't % mean?
In MySQL, % does not represent a decimal.
Detailed description:
In MySQL, % is widely used for wildcard matching and can match any number of any characters. For example:
LIKE '�c%'
matches any string that contains the "abc" substring. WHERE name LIKE 'J%'
Matches all names starting with the letter "J". However, % cannot be used to represent decimals. Therefore, the following query will not work correctly:
<code class="sql">SELECT * FROM table WHERE price = 10.5%;</code>
To match decimals, use the BETWEEN operator or comparison operators like >= and <code><=
. For example:
SELECT * FROM table WHERE price BETWEEN 10 AND 11; SELECT * FROM table WHERE price >= 10.5;
The above is the detailed content of What cannot be represented by % in mysql. For more information, please follow other related articles on the PHP Chinese website!