| |

VerySource

 Forgot password?
 Register
Search
View: 866|Reply: 1

On the problem of multi-table join query to eliminate duplicate rows

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2021-3-12 10:00:01
| Show all posts |Read mode
I have 3 tables, a product table, and 2 different types of classification tables. One is necessary for classification and the other is not necessary. My SQL statement is as follows:

select distinct(int_product_id),str_productCatalog_title,
str_product_name,str_brandcatalog_title,str_Product_ProduceArea,
str_Product_Standard,dat_Product_CreateTime,int_Product_IsFocus,
int_Product_IsHot,int_Product_SortID
FROM Sunyes_Product inner join Sunyes_ProductCatalog on
str_Product_CatalogCode = str_ProductCatalog_SelfCode left JOIN
Sunyes_ProductBrandCatalog ON str_Product_BrandCode=str_BrandCatalog_SelfCode

But there are many duplicate rows in the queried data. Why?
How to modify it?
Reply

Use magic Report

0

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2021-3-12 14:45:01
| Show all posts
The most likely reason is that str_Product_CatalogCode in Sunyes_ProductCatalog cannot uniquely identify a record and is duplicated; or str_Product_BrandCode in Sunyes_ProductBrandCatalog is duplicated.
How to fix this problem depends on which of the three tables all the fields in your SELECT are taken from.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list