Sql查询返回重复的行

时间:2013-09-24 17:43:21

标签: mysql sqlite

请在下面找到查询:

SELECT a.reco_index_content_code,a.reco_index_content_name, a.reco_index_user_action_download_file, 
        CASE WHEN b.refdata_profession_passion_code LIKE '%-%'
                 THEN 'passion'
                 ELSE 'profession' 
             END AS passion_or_profession
FROM tbl_reco_index_contents a 
INNER JOIN tbl_reference_databases b
ON a.reco_index_content_code = b.refdata_content_code
WHERE a.reco_index_user_action_installed = 1 and a.user_profile_number =  1

查询返回重复的某些行。如果查询不是自我解释,我将不得不回复更多详细信息。

非常感谢任何帮助

查询结果

AAY_AAYAB_FTD00028  PGA TOUR            /mnt/sdcard/googleCheckout/PGA TOUR.apk profession
AAB_AABAE_FTD00071  PD Central          /mnt/sdcard/googleCheckout/Parkinson's Central.apk   passion
AAB_AABAE_FTD00071  PD Central          /mnt/sdcard/googleCheckout/Parkinson's Central.apk  passion
AAB_AABAE_FTD00072  com.diablo.psychiatry   /mnt/sdcard/googleCheckout/Psychiatry-Neurology Pro.apk passion
AAB_AABAE_FTD00072  com.diablo.psychiatry   /mnt/sdcard/googleCheckout/Psychiatry-Neurology Pro.apk passion
AAB_AABAA_FTD00074  Glasgow                 /mnt/sdcard/googleCheckout/Glasgow Coma Scale Free.apk  passion
AAB_AABAA_FTD00073  FOUR Score          /mnt/sdcard/googleCheckout/FOUR score.apk   passion
AAB_AABAA_FTD00075  Qx Calculate             /mnt/sdcard/googleCheckout/Calculate by QxMD.apk   passion

1 个答案:

答案 0 :(得分:1)

根据您显示的结果,一个简单的DISTINCT将删除重复项,因为列中的所有值在两行中都相同,

SELECT DISTINCT .....