簡體   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