Search before asking
Version
- 2.1.7 (upgrading from 2.1.2)
What's Wrong?
mysql> select * from
(
select
SUBSTRING_INDEX(name, 'A', 1) t1,
LEFT(name, LOCATE('A', name)-1) t2,
name,
age,
code
from
(
SELECT
name,
age,
code
FROM (
SELECT '哈哈哈AAA' name, 20 age, '1' code
UNION
SELECT '哈哈哈AA+' name, 21 age, '2' code
UNION
SELECT '哈哈哈AA' name, 22 age, '3' code
UNION
SELECT '哈哈哈AA(2)' name, 23 age, '4' code
UNION
SELECT '哈哈哈AA-' name, 24 age, '5' code
) a
) b
) c
where t1 = '哈哈哈';
+--------+--------+-------------+-----+------+
| t1 | t2 | name | age | code |
+--------+--------+-------------+-----+------+
| 哈哈哈 | 哈哈哈 | 哈哈哈AA- | 24 | 5 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AAA | 20 | 1 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA+ | 21 | 2 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA | 22 | 3 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA(2) | 23 | 4 |
+--------+--------+-------------+-----+------+
5 rows in set (0.17 sec)
mysql> select * from
(
select
SUBSTRING_INDEX(name, 'A', 1) t1,
LEFT(name, LOCATE('A', name)-1) t2,
name,
age,
code
from
(
SELECT
name,
age,
code
FROM (
SELECT '哈哈哈AAA' name, 20 age, '1' code
UNION
SELECT '哈哈哈AA+' name, 21 age, '2' code
UNION
SELECT '哈哈哈AA' name, 22 age, '3' code
UNION
SELECT '哈哈哈AA(2)' name, 23 age, '4' code
UNION
SELECT '哈哈哈AA-' name, 24 age, '5' code
) a
) b
) c
where t1 = '哈哈哈';
+--------+--------+-------------+-----+------+
| t1 | t2 | name | age | code |
+--------+--------+-------------+-----+------+
| 哈哈哈 | 哈哈哈 | 哈哈哈AA- | 24 | 5 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA(2) | 23 | 4 |
| 哈哈哈 | 哈哈哈 | 哈哈哈AA+ | 21 | 2 |
+--------+--------+-------------+-----+------+
3 rows in set (0.10 sec)
we use SUBSTRING_INDEX in the production, now we have to use LEFT+LOCATE for replacement.
What You Expected?
fix the query result bug
How to Reproduce?
Anything Else?
No response
Are you willing to submit PR?
Code of Conduct
Search before asking
Version
What's Wrong?
we use
SUBSTRING_INDEXin the production, now we have to useLEFT+LOCATEfor replacement.What You Expected?
fix the query result bug
How to Reproduce?
Anything Else?
No response
Are you willing to submit PR?
Code of Conduct