繁体   English   中英

字段列表中的“大小”列不明确

[英]Column 'size' in field list is ambiguous

无效的SQL:

SELECT
 info_hash,
 size,
 comment,
 created_by,
 announce_list,
 completed_by, 
 completed,
 seeders,
 leechers,
 ulspeed,
 dlspeed,
 dateline,
 thumbnail_dateline, 
 filename,
 filesize,
 visible,
 attachmentid,
 counter,
 postid, 
 IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail,
 thumbnail_filesize,
 attachmenttype.thumbnail AS build_thumbnail,
 attachmenttype.newwindow
FROM attachment
LEFT JOIN attachmenttype AS attachmenttype USING (extension)
WHERE postid IN (-1,2)
ORDER BY attachmentid;

MySQL错误:字段列表中的列“大小”不明确,错误编号:1052

这意味着attachmentattachmenttype都可能是size

如果您限定列名,那么您将永远不会遇到此类问题。

@GordonLinoff有正确的答案。 但是,如果您只是从某个地方复制了此代码,那么您将很难理解他在说什么。 (也很好地问是更好的)。

以此为基础。 注意如何将A.添加到size如果任何字段再次不正确,则必须向其中添加A.T. .。

SELECT info_hash, 
 A.size,
 comment,
 created_by,
 announce_list,
 completed_by, 
 completed, 
 seeders, 
 leechers, 
 ulspeed, 
 dlspeed,
 dateline, 
 thumbnail_dateline, 
 filename, 
 filesize, 
 visible,
 attachmentid, 
 counter,
 postid,
 IF(thumbnail_filesize > 0, 1, 0) AS hasthumbnail,
 thumbnail_filesize,
 T.thumbnail AS build_thumbnail, 
 T.newwindow
FROM attachment A
LEFT JOIN attachmenttype AS T USING (extension)
WHERE A.postid IN (-1,2)
ORDER BY A.attachmentid;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM