[英]Column 'size' in field list is ambiguous
Invalid SQL: 无效的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 Error : Column 'size' in field list is ambiguous Error Number : 1052 MySQL错误:字段列表中的列“大小”不明确,错误编号:1052
This means that size
is presumably in both attachment
and attachmenttype
. 这意味着
attachment
和attachmenttype
都可能是size
。
If you qualify your column names, then you won't ever have this type of problem. 如果您限定列名,那么您将永远不会遇到此类问题。
@GordonLinoff has the right answer. @GordonLinoff有正确的答案。 But if you simply copied this code from somewhere, then you'll have difficulty understanding what he's saying.
但是,如果您只是从某个地方复制了此代码,那么您将很难理解他在说什么。 (Also asking nicely is better).
(也很好地问是更好的)。
Use this as a basis. 以此为基础。 Notice how I added
A.
to size
If any field is incorrect again, you'll have to add either A.
or T.
to it. 注意如何将
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.