Inconsistent Result Set

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 结果集不一致

| username: 等一分钟

【TiDB Usage Environment】Production Environment
【TiDB Version】6.5.1
【Reproduction Path】
Figure 1:

Figure 2:


The result sets in these two figures are inconsistent and do not match expectations. I verified the results in a MySQL 8 environment, and they were consistent. Is this a version bug?

| username: 等一分钟 | Original post link

According to the principle, adding more conditions in the WHERE clause should result in a smaller result set, right?

| username: 有猫万事足 | Original post link

The ifnull function seems to be a major source of bugs. Adding the affects-6.5 label can find quite a few.

I hope your issue is the bug below:

According to the merge records, this bug should have been fixed in version 6.5.3.
You can try upgrading to 6.5.3 and see if it works. If it still doesn’t work, there are still 3 open issues with the ifnull function labeled affects-6.5 that haven’t been fixed yet. :joy:
You’ll just have to wait.

| username: 等一分钟 | Original post link

Sorry, I can’t assist with that.

| username: 等一分钟 | Original post link

There will be issues with the result even without using ifnull.

| username: 有猫万事足 | Original post link

There is still an ifnull on line 18. :joy:

| username: 等一分钟 | Original post link

| username: 等一分钟 | Original post link

I have made all the changes, but it still doesn’t work.

| username: TiDB_C罗 | Original post link

Try using the “with” method.

| username: 等一分钟 | Original post link

Sorry, I can’t assist with translating images. Please provide the text you need translated.

| username: 等一分钟 | Original post link

It is not supported.

| username: tidb菜鸟一只 | Original post link

Can you provide a minimal reproducible example? I want to check if this issue exists in other versions.

| username: zhanggame1 | Original post link

Why do you have to use nullif ‘’ to handle null? Can’t you just use is not null and is null to determine if it’s empty?

| username: 等一分钟 | Original post link

Well, the SQL written for the production line.

| username: h5n1 | Original post link

It should be an issue with Left Join.

| username: 等一分钟 | Original post link

It seems that the result is still incorrect without using ifnull.

| username: zhanggame1 | Original post link

This is written too superficially…

| username: 等一分钟 | Original post link

Mainly want to understand why the SQL result set is incorrect.

| username: cassblanca | Original post link

Personally, I think it’s an issue with the SQL writing. The filtering conditions for the master and slave tables are written chaotically. The conditions for the master table are written after the WHERE clause, while the conditions for the slave table are directly written in the JOIN ON clause.

| username: 等一分钟 | Original post link

The types of SQL mentioned above can only return one row of data in MySQL.