gpt4 book ai didi

mysql - 这个查询给出了重复的记录,这个查询有什么问题?

转载 作者:搜寻专家 更新时间:2023-10-30 21:45:52 24 4
gpt4 key购买 nike

这是给出重复结果的查询:

SELECT a.applicant_particular_id, a.name, a.father_name, a.quota_id, 
c.hafiz_quran_marks, b.form_status
FROM applicant_particular a,admission_choices b, academic_background c
WHERE b.applicant_particular_id=a.applicant_particular_id
AND c.applicant_particular_id=a.applicant_particular_id
AND a.quota_id='18'
AND b.form_status='RECEIVED'

这是第一个表“applicant_particular”

The red highlighted rows are repeating and hafiz_quran_marks is showing with all rows

这是第一个表“applicant_particular”

   applicant_particular_id   |   name   |   father_name   |    quota_id


1 John Micheal 18
2 khan ali 19

这是第二个表“admission_choices”

   choice_id   |   form_status   |   applicant_particular_id   |    program_id


1 PENDING 2 19
2 RECEIVED 1 18

这是第三个表“academic_background”

   background_id   |   hafiz_marks   |   applicant_particular_id   


1 20 2
2 30 1

最佳答案

尝试切换到显式连接,然后在 distinct 中进行 bash 以取得良好效果

SELECT distinct 
a.applicant_particular_id,
a.name,
a.father_name,
a.quota_id,
c.hafiz_quran_marks,
b.form_status
FROM applicant_particular a
INNER JOIN admission_choices b
ON b.applicant_particular_id=a.applicant_particular_id
INNER JOIN academic_background c
ON c.applicant_particular_id=a.applicant_particular_id
WHERE a.quota_id='18'
AND b.form_status='RECEIVED'

关于mysql - 这个查询给出了重复的记录,这个查询有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39365787/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com