Rising Lee
Rising Lee

Reputation: 1165

MySQL combine two SELECT statements using AND

I've been trying to combine these two statements for two weeks already but to no avail. I've tried using UNION but it produces "the number of columns are different" error. Now I'm hoping to use AND clause to combine these statements. Thanks in advance :)

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

Upvotes: 0

Views: 81

Answers (2)

Alexey Palamar
Alexey Palamar

Reputation: 1430

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

Upvotes: 3

Manolo
Manolo

Reputation: 26370

Is this what you're trying to do?:

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

Upvotes: 0

Related Questions