GeekInterview.com
Series: Subject:
Question: 18 of 165

MySql Query problem

I have two Table A and B.
With table A I fired a query to get a count, and a query with table B to get a count.
now I want total of both count.
But I want to this all in one query.


Example:- I fired tqo queries as-

1- select DATE(Today_DATE), count(1) from table DAY1 group by DATE(Today_DATE);

2- Select DATE(Yesturday_DATE), count(1) from table DAY2 group by DATE(Yesturday_DATE);

Here both table give separate counts and we can add these count for single result,
But I want all this work in a single query
Asked by: GAUTAMJANGRA | Member Since Mar-2011 | Asked on: Jun 16th, 2011

View all questions by GAUTAMJANGRA   View all answers by GAUTAMJANGRA

Showing Answers 1 - 1 of 1 Answers

You can do it like this

SELECT (SELECT COUNT(1) FROM table DAY1 GROUP BY DATE(Today_DATE)) + (SELECT COUNT(1) FROM table DAY2 GROUP BY DATE(Yesterday_DATE)) AS TotalCount FROM day1 LIMIT 1

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.