mysql count from two tables and give combined count of string

<p>I have two tables where common column is location,i am looking for the count of the locations from both the tables and display a combined count.</p><pre><br /><code> Table-1 <br />+-------------+<br />| Location |<br />+-------------+<br />| USA |<br />| INDIA |<br />| UK |<br />| INDIA |<br />+-------------+<br /><br /> Table -2<br />+-------------+<br />| Location |<br />+-------------+<br />| INDIA |<br />| INDIA |<br />| USA |<br />+-------------+<br /></code><br /></pre><p>Here the count from table one is :</p><pre><br /><code>+-------------+--------+<br />| Location | COUNT |<br />+-------------+--------+<br />| USA | 1 |<br />| INDIA | 2 |<br />| UK | 1 |<br />+-------------+--------+<br /></code><br /></pre><p>Count from table 2 is :</p><pre><br /><code>+-------------+--------+<br />| Location | COUNT |<br />+-------------+--------+<br />| USA | 1 |<br />| INDIA | 2 |<br />+-------------+--------+<br /></code><br /></pre><p>This count am getting by :</p><pre><br /><code>SELECT Location, COUNT(*) AS COUNT FROM Table-1 GROUP BY Location;<br />SELECT Location, COUNT(*) AS COUNT FROM Table-2 GROUP BY Location;<br /></code><br /></pre><p>But i want the combined count from the two tables which looks like:</p><pre><br /><code>+-------------+--------+<br />| Location | COUNT |<br />+-------------+--------+<br />| USA | 2 |<br />| INDIA | 4 |<br />| UK | 1 |<br />+-------------+--------+<br /></code><br /></pre><p>Thank you in advance.</p><br /><h2>Click here view more answers <a href="http://ift.tt/1OrGIca">http://ift.tt/1OrGIca</a></h2>

Nhận xét

Bài đăng phổ biến từ blog này

Align div to bottom of the page in bootstrap

Align elements inside an tag vertically

Javascript is unable to stop page loading