'An error occurred when MySQL used leftjoin
When I use the left join in mysql, there are two pieces of data, but I'm sure only one will come out
sql is
SELECT bs.id,distribute_user_id,manager_id,phone,manager_name
FROM bank_integral_distribute_serial bs
LEFT JOIN manager mi ON bs.distribute_user_id = mi.manager_id
WHERE bs.phone = "13978836385"

Respective data sql is
SELECT *
FROM bank_integral_distribute_serial
WHERE distribute_user_id="1475118915817316353"

sql is
SELECT *
FROM manager
WHERE manager_id = "1475118915817316353"

I also check the mobile phone number, and there is only one
Questions: Why are there two pieces of data
Solution 1:[1]
The reason is that the MySQL comparison types are inconsistent.
you can see
https://dev.mysql.com/doc/refman/5.7/en/type-conversion.html
distribute_user_id The original table is bigint : manager_id is varchar
SELECT IF("1475118915817316353"=1475118915817316354,"equal","unequal") //The results are equal
SELECT IF("1475118915817316311"=1475118915817316360,"enqual","unequal") //The results are equal
//left?[1475118915817316224?1475118915817316480] The results are equal, both with the right side
SELECT IF("1475118915817316480"=1475118915817316360,"enqual","unenqual")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
