0
我有一個查詢,我使用的是使用來自多個列的ID來引用一個表來獲取有關該ID的信息。這裏是代碼:MySQL Query多對一連接
SELECT `Events`.EventID,
`Events`.AssociationID,
`Events`.Association2ID,
`Events`.Association3ID,
`Events`.Association4ID,
`Events`.Association5ID,
`Events`.DateFrom,
`Events`.DateTo,
`Events`.EventName,
`Events`.VenueID,
`Events`.TestnTune,
`Events`.ShownShine,
`Events`.SpecialInfo,
`Events`.OtherInfo,
`Events`.Rating,
`Events`.EventOverlay,
`Events`.HavePictures,
`Events`.IncludeInSchedule,
`Events`.EventURL,
Associations.Active,
Associations.Acronym,
Associations.OrgName,
Associations.WebURL,
Associations.LogoURL,
Venues.LocationName,
Venues.Location,
Venues.longetude,
Venues.latitude,
Venues.Directions,
Venues.SitePros,
Venues.SiteCons,
Venues.BasicInfo,
Venues.SiteRating,
Venues.HostedEvents,
Venues.CurrentWeather
FROM `Events`
LEFT JOIN Associations ON `Events`.AssociationID = Associations.AssociationID
AND `Events`.Association2ID = Associations.AssociationID
AND `Events`.Association3ID = Associations.AssociationID
AND `Events`.Association4ID = Associations.AssociationID
AND `Events`.Association5ID = Associations.AssociationID
LEFT JOIN Venues ON `Events`.VenueID = Venues.VenueID
WHERE `Events`.DateFrom >= NOW()
我想要做的是捕獲有關每個ID的詳細信息。我無法弄清楚這是如何完成的。例如:
For Association2ID:
Associations.Active,
Associations.Acronym,
Associations.OrgName,
Associations.WebURL,
Associations.LogoURL
For Association3ID
Associations.Active,
Associations.Acronym,
Associations.OrgName,
Associations.WebURL,
Associations.LogoURL,
etc.
的正常方式保留5列好了,你似乎是選擇這些列。你想成爲什麼?我看到你可能需要使用`或`而不是`和` - 並重新設計數據庫以將其放入第一個正常形式! – 2010-12-09 00:50:43