MySQL使用AND组合两个SELECT语句

时间:2014-04-19 09:25:18

标签: mysql

我已经尝试将这两个陈述合并两周,但无济于事。我尝试过使用UNION,但它会生成"列数不同"错误。现在我希望使用AND子句来组合这些语句。在此先感谢:)

SELECT te_events.eventTitle,
       te_category.catDesc
FROM te_events
JOIN te_category ON te_events.catID=te_category.catID
ORDER BY te_events.eventTitle

SELECT eventStartDate,
       eventEndDate,
       eventPrice,
       eventDescription
FROM te_events

2 个答案:

答案 0 :(得分:3)

SELECT e.eventStartDate,
       e.eventEndDate,
       e.eventPrice,
       e.eventDescriptio,
       e.eventTitle,
       c.catDesc
FROM te_events AS e
LEFT JOIN te_category AS c ON e.catID=c.catID
ORDER BY e.eventTitle

答案 1 :(得分:0)

这是你正在尝试做的事情吗?:

SELECT te_events.eventTitle,
       te_events.eventStartDate,
       te_events.eventEndDate,
       te_events.eventPrice,
       te_events.eventDescription,
       te_category.catDesc
FROM te_events
JOIN te_category ON te_events.catID=te_category.catID
ORDER BY te_events.eventTitle