Home >Database >Mysql Tutorial >How does MySQL calculate if we write non-numeric text between numbers in a string when adding numbers contained in quotes?

How does MySQL calculate if we write non-numeric text between numbers in a string when adding numbers contained in quotes?

王林
王林forward
2023-09-04 14:45:021029browse

在添加引号中包含的数字时,如果我们在字符串的数字之间写入非数字文本,MySQL 如何计算?

Suppose we try to add non-numeric text between numbers in a string, then MySQL will use only the first number of the string to calculate the addition, and Comes with a caveat. The following example will demonstrate this −

Example

mysql> Select '1525 * 2' + '200'As Total;
+-------+
| Total |
+-------+
| 1725  |
+-------+
1 row in set, 1 warning (0.00 sec)

It is clear from the above query that MySQL only uses the first number (i.e. 1525) to calculate the addition and ignores non- Digital text.

The above is the detailed content of How does MySQL calculate if we write non-numeric text between numbers in a string when adding numbers contained in quotes?. For more information, please follow other related articles on the PHP Chinese website!

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