我在三个表中使用内部联接。我只想获得唯一记录,而不是重复记录。因此,我将SELECT DISTINCT
与内部联接一起使用。但是仍然获得重复记录。
我的代码
SELECT DISTINCT Submission.MID AS Expr16,
RevAssaignments.Rev1Name AS Expr18,
RevAssaignments.Rev2Name AS Expr19,
RevAssaignments.Rev3Name AS Expr20,
RevAssaignments.Rev1Status AS Expr21,
RevAssaignments.Rev2Status AS Expr22,
RevAssaignments.Rev3Status AS Expr23,
Submission.Title AS Expr2,
Submission.SID AS Expr1,
Files.PaperKey AS Expr7,
Submission.CoAuth AS Expr3,
Submission.Email AS Expr4,
Submission.CopyRightDate AS Expr5,
Submission.Status AS Expr6,
Files.*
FROM RevAssaignments
INNER JOIN Submission ON RevAssaignments.SID = Submission.SID
INNER JOIN Files ON Submission.SID = Files.SID
WHERE (Submission.Status = 'ACCEPTED ')
ORDER BY Expr16
输出
I-2012-10-355 Modified Sierpinski Carpet Fractal Antenna for Wireless Applications 354 2701318277.pdf Kuldip Pahwa
I-2012-10-355 Modified Sierpinski Carpet Fractal Antenna for Wireless Applications 354 1488315706.pdf Kuldip Pahwa
I-2012-10-355 Modified Sierpinski Carpet Fractal Antenna for Wireless Applications 354 3539969905.pdf Kuldip Pahwa
I-2012-12-379 Modified Dither Optical Phase Locked Loop for Inter-satellite Communications 378 1978719613.pdf A.BANERJEE
I-2012-12-379 Modified Dither Optical Phase Locked Loop for Inter-satellite Communications 378 1063820967.pdf A.BANERJEE
I-2012-12-379 Modified Dither Optical Phase Locked Loop for Inter-satellite Communications 378 9443420594.pdf A.BANERJEE
I-2012-12-385 A Sampling Oscilloscope Based System with Active RF/IF Load-pull for Multi-Tone Non-linear Device Characterization 384 1383013331.pdf Dr. Muhammad Akmal Chaudhary
I-2013-4-435 DESIGN OF MICROSTRIP YAGI UDA ANTENNA WITH THREE PARASITIC ELEMENTS AT 2.5 GHz 434 2012614214.pdf satyandra singh lodhi
I-2013-4-435 DESIGN OF MICROSTRIP YAGI UDA ANTENNA WITH THREE PARASITIC ELEMENTS AT 2.5 GHz 434 1349118729.pdf satyandra singh lodhi
所需的输出
I-2012-10-355 Modified Sierpinski Carpet Fractal Antenna for Wireless Applications 354 3539969905.pdf Kuldip Pahwa
I-2012-12-379 Modified Dither Optical Phase Locked Loop for Inter-satellite Communications 378 9443420594.pdf A.BANERJEE
I-2012-12-385 A Sampling Oscilloscope Based System with Active RF/IF Load-pull for Multi-Tone Non-linear Device Characterization 384 1383013331.pdf Dr. Muhammad Akmal Chaudhary
I-2013-4-435 DESIGN OF MICROSTRIP YAGI UDA ANTENNA WITH THREE PARASITIC ELEMENTS AT 2.5 GHz 434 1349118729.pdf satyandra singh lodhi
答案 0 :(得分:1)
您可能会注意到,文件名是不同的(2701318277.pdf,1488315706.pdf,9443420594.pdf),不同的命令统一了所有共享相同字段值的所有记录)
答案 1 :(得分:0)
这是因为在“文件”表中进行联接有多个结果。如果仅对“文件”表中的1行执行联接,则可以达到所需的输出。
SELECT DISTINCT Submission.MID AS Expr16
, RevAssaignments.Rev1Name AS Expr18
, RevAssaignments.Rev2Name AS Expr19
, RevAssaignments.Rev3Name AS Expr20
, RevAssaignments.Rev1Status AS Expr21
, RevAssaignments.Rev2Status AS Expr22
, RevAssaignments.Rev3Status AS Expr23
, Submission.Title AS Expr2
, Submission.SID AS Expr1
, Files.PaperKey AS Expr7
, Submission.CoAuth AS Expr3
, Submission.Email AS Expr4
, Submission.CopyRightDate AS Expr5
, Submission.Status AS Expr6
, Files.*
FROM RevAssaignments
INNER JOIN Submission ON RevAssaignments.SID = Submission.SID
INNER JOIN Files ON Files.SID = ( SELECT Files.FID FROM Files WHERE Files.SID = Submission SID (ORDER BY if needed) LIMIT 1)
WHERE (Submission.Status = 'ACCEPTED ') ORDER BY Expr16