Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Is this the correct query?
SELECT COUNT(*),outlet_itembarcode.outletcode FROM outlet_itembarcode INNER JOIN outlet_itemproductcode
ON outlet_itembarcode.itemcode = outlet_itemproductcode.itemcode GROUP BY outlet_itembarcode.outletcode;
My intention is to join 2 table which have similar columns and count the total rows for certain code; in this case, the outletcode. I have 14 outletcode in both tables. I want to compare the results with my other temporary table which contain the exact total of rows for each outletcode. This 2 tables are a separation from the original temp table where one with barcode and another with productcode only. This should be accurate since the rule is if the data have the barcode it will not contain the productcode and vice versa. I did run this query but it seems that the results is not accurate. I'm using SQLyog on MySQL 4.1.
1 Answer
- 9 years agoFavorite Answer
SELECT COUNT(*), outletcode
FROM
(
SELECT outletcode
FROM outlet_itemproductcode
UNION ALL
SELECT outletcode
FROM outlet_itembarcode
) AS A
GROUP BY outletcode
this should apply it.