【发布时间】:2013-10-01 04:21:16
【问题描述】:
请找到下面给出的查询:
SELECT DISTINCT
reco_index_content_code,
reco_index_content_name,
reco_index_content_url
FROM tbl_reco_index_contents
WHERE
reco_index_user_action_at_select = 1
AND user_profile_number = 1
我需要选择 reco_index_content_name 来区分。
应该如何修改上述查询,以实现这一点,使得没有重复的reco_index_content_name 行?
【问题讨论】:
-
您将如何处理以下
reco_index_content_code?例如,只选择最低的代码? -
如果有重复,你想返回哪一行。请注意,“不关心”通常表示设计不佳。
-
@Strawberry -- 我明白,但我这样做是为了临时修复演示。可以是任意行。
-
那么它可以是任何值吗?对其他列使用常量:
SELECT DISTINCT '' AS reco_index_content_code, reco_index_content_name, '' AS reco_index_content_url FROM ...