0

我有一个保存产品信息的 SQL 数据库,包括产品的名称和描述。

它目前的设置方式是这样的:

+-------------+-------------+------------------+--------------------------------+
| products_id | language_id | products_name    | products_description           |
+-------------+-------------+------------------+--------------------------------+
|           1 |           1 | A19845002        | CONE DRIVE ASSEMBLY            |
|           1 |           2 | A19845002        | CONE DRIVE ASSEMBLY            |
|        4619 |           1 | A51959001        | CONE DRIVE SPACER              |
|        4619 |           2 | A51959001        | CONE DRIVE SPACER              |
|       13600 |           1 | A18535004        | CONE DRIVE UNIT                |
|       13600 |           2 | A18535004        | CONE DRIVE UNIT                |
|       13701 |           1 | A17236001GEARSET | CONE DRIVE GEARSET             |
|       13701 |           2 | A17236001GEARSET | CONE DRIVE GEARSET             |
|       14388 |           1 | A18535003        | CONE DRIVE UNIT                |
|       14388 |           2 | A18535003        | CONE DRIVE UNIT                |
|       14389 |           1 | A18535002        | CONE DRIVE UNIT                |
|       14389 |           2 | A18535002        | CONE DRIVE UNIT                |
|       14390 |           1 | A18535001        | CONE DRIVE UNIT                |
|       14390 |           2 | A18535001        | CONE DRIVE UNIT                |
|       14727 |           1 | A19346006        | CONE DRIVE SPEED REDUCER       |
|       14727 |           2 | A19346006        | CONE DRIVE SPEED REDUCER       |
|       14859 |           1 | A18957002        | CONE DRIVE GEARMOTOR UNIT      |
|       14859 |           2 | A18957002        | CONE DRIVE GEARMOTOR UNIT      |
|       14867 |           1 | 604037           | CONE DRIVE GEARMOTOR           |
|       14867 |           2 | 604037           | CONE DRIVE GEARMOTOR           |
|       15182 |           1 | A17236001        | CONE DRIVE UNIT SM-502000-AJ   |
|       15182 |           2 | A17236001        | CONE DRIVE UNIT SM-502000-AJ   |
|       15410 |           1 | A19346004        | CONE DRIVE WORM REDUCER        |
|       15410 |           2 | A19346004        | CONE DRIVE WORM REDUCER        |
|       15751 |           1 | 604036           | CONE DRIVE GEARMOTOR 2.75 BORE |
|       15751 |           2 | 604036           | CONE DRIVE GEARMOTOR 2.75 BORE |
|       15752 |           1 | 604035           | MSR 50 CONE DRIVE GEARMOTOR    |
|       15752 |           2 | 604035           | MSR 50 CONE DRIVE GEARMOTOR    |
|       15842 |           1 | A19346005        | CONE DRIVE WORM REDUCER        |
|       15842 |           2 | A19346005        | KEGELRÄDER WORM REDUCER        |
+-------------+-------------+------------------+--------------------------------+

products_description当它相同products_id但不同时,它想通过并找出不同的地方language_id。(1 应该是英语,2 应该是德语)。如果我对此运行查询,我希望有一个简单的方法来找到 CONE DRIVE WORM REDUCER/KEGELRÄDER WORM REDUCER(所以product_idor product_name)。

我将如何使用 mysql 执行此操作?我真的不习惯做很多数据库的事情,但我需要找出这些产品中的任何一个是否得到了适当的处理。

4

2 回答 2

1

试试这个:

SELECT DISTINCT products_id
FROM products_table -- assumed
GROUP BY products_description
  HAVING COUNT(products_id) > 1

应该为您提供一个结果,其中包含已翻译其描述的产品的产品 ID。如果您决定要使用未翻译其描述的产品的 ID,请将子句>中的测试替换为.HAVING=

于 2013-11-13T17:44:00.683 回答
0
SELECT P1.PRODUCTS_ID, P1.PRODUCTS_DESCRIPTION, P2.PRODUCTS_DESCRIPTION
FROM PRODUCTS AS P1
INNER JOIN PRODUCTS AS P2
ON P2.PRODUCTS_ID = P1.PRODUCTS_ID
AND P1.LANGUAGE_ID <> P2.LANGUAGE_ID
AND P1.PRODUCTS_DESCRIPTION<> P2.PRODUCTS_DESCRIPTION
于 2013-11-13T17:44:36.037 回答