0

我想今天的咖啡不够浓。我需要查询表 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 查询其他表?

谢谢。

4

2 回答 2

3

应该fb-celebotd(用破折号)是fb_celebotd(用下划线)?如果表名有破折号,那么您必须引用表名:"fb-celebotd"。否则,破折号被视为减号并尝试从 fb 中减去 celebotd(均未知)。

于 2010-06-21T19:05:01.303 回答
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
于 2010-06-21T19:12:09.293 回答