How to Merge 2 SELECT statements

-1

How to merge these 2 selects ?

MY TABLES

   EVENT  TITLE DESCRIPTION CATEGORY_ID 
   CATEGORY NAME COLOR ICON DESCRIPTION

this select below works perfectly makes the count right I need to do the same without count on the other two selects

  SELECT category.*,(SELECT COUNT(*) FROM event 
  WHERE category_id = category.id)as total FROM category

I've tried it this way

  "SELECT category.* FROM event WHERE category_id = 4) 
   FROM category ORDER BY MONTH(date_at)DESC "

In the other Table

    SELECT * FROM event WHERE DATE(date_at) = CURDATE()

   "SELECT category.* FROM event WHERE category_id = 5) 
   FROM category ORDER DATE(date_at) = CURDATE() "

I was able to do this

SELECT  *, color
     FROM event , category 
    WHERE  event.id = event.category_id ; 

So I could not place WHERE DATE (date_at) = CURDATE ()

Someone?

    
asked by anonymous 10.11.2016 / 20:00

1 answer

1

Try this:

SELECT 

c.NAME,
c.COLOR,
c.ICON,
c.DESCRIPTION,
count(e.DESCRIPTION) as count_evt

FROM category c
join event e on e.category_id = c.id

group by 
c.NAME,
c.COLOR,
c.ICON,
c.DESCRIPTION;
    
10.11.2016 / 21:16