Invalid 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
This means that size
is presumably in both attachment
and attachmenttype
.
If you qualify your column names, then you won't ever have this type of problem.
@GordonLinoff has the right answer. 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.
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.