我有3个表:te_event,te_venue,te_category。
te_event表包含列:categoryID, venueID, event description, title, date, price.
te_venue表包含列:venueID, venueName and location.
te_category包含列:catID and catDesc.
这是我的查询
SELECT *
FROM te_events
INNER JOIN te_venue
ON te_events.venueid = te_venue.venueid
INNER JOIN te_category
ON te_events.catid = te_category.catid
但它通过重新编写ID
来显示 eventID | eventTitle | eventDescription |venueID | catID| eventStartDate |eventEndDate |eventPrice | venueID | venueName | location| catID | catDesc
答案 0 :(得分:1)
SELECT e.event_description, e.title,e.date,e.price,v.venueName,v.location,c.catDesc
FROM te_events e
INNER JOIN te_venue v ON e.venueID = v.venueID
INNER JOIN te_category c ON e.catID = c.catID
请参阅下面的结果
答案 1 :(得分:1)
为什么不选择您需要的列?例如:
SELECT E.eventID, E.eventTitle, E.eventDescription,
E.eventStartDate, E.eventEndDate, E.eventPrice
E.catID, V.venueID, V.venueName, V.location
FROM te_events AS E
INNER JOIN te_venue AS V ON E.venueID = V.venueID
INNER JOIN te_category AS C ON E.catID = C.catID
它可能会长一点,但它可能仍然很可能会给你你期望的结果。
干杯&好运。
答案 2 :(得分:0)
SELECT DISTINCT t1.categoryID,t1.venueID,t1.eventDescription,t1.title,t1.date,t1.price,t2.venueName, t2.location, t3.catDesc FROM te_events AS t1
INNER JOIN te_venue AS t2 ON te_events.venueID = te_venue.venueID
INNER JOIN te_category AS t3 ON te_events.catID = te_category.catID
我希望它有所帮助