我认为今天的咖啡不够浓郁。我需要查询表fb-celebotd以获得与fb-celebotd.celebdate匹配的photoid。所需的大多数其他信息都取决于照片表。
以下是给我一个mysql错误:
Select photos.*,photographer.name, events.eventname, events.eventhome, subevents.subeventname, photodir.photodir, fb-celebotd.celebdate, fb-celebotd.trivia
from photos
LEFT JOIN fb-celebotd ON (photos.photoid = fb-celebotd.photoid)
LEFT JOIN photodir ON (photos.photodirid = photodir.photodirid)
LEFT JOIN photographer ON (photos.photographerid = photographer.photographerid)
LEFT JOIN events ON (photos.eventid = events.eventid)
LEFT JOIN subevents ON (photos.subeventid = subevents.subeventid)
WHERE fb-celebotd.celebdate=1277092800
这在一个查询中是可行的,还是我必须首先查询fb-celebotd的photoid和琐事,然后根据photoid查询其他表?
感谢。
答案 0 :(得分:3)
fb-celebotd
(带破折号)是fb_celebotd
(带下划线)吗?如果表名有破折号,那么您必须引用表名:"fb-celebotd"
。否则,短划线将被视为减号,并尝试从fb中减去celebotd(均为未知)。
答案 1 :(得分:1)
如果你真的有一个名为fb-celebotd的表,那么每次在查询中使用它时都需要引用表名:
Select photos.*,photographer.name, events.eventname, events.eventhome, subevents.subeventname, photodir.photodir, `fb-celebotd`.celebdate, `fb-celebotd`.trivia
from photos
LEFT JOIN `fb-celebotd` ON (photos.photoid = `fb-celebotd`.photoid)
LEFT JOIN photodir ON (photos.photodirid = photodir.photodirid)
LEFT JOIN photographer ON (photos.photographerid = photographer.photographerid)
LEFT JOIN events ON (photos.eventid = events.eventid)
LEFT JOIN subevents ON (photos.subeventid = subevents.subeventid)
WHERE `fb-celebotd`.celebdate=1277092800