{"id":2105,"date":"2014-12-18T13:07:56","date_gmt":"2014-12-18T21:07:56","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=2105"},"modified":"2015-04-07T08:35:12","modified_gmt":"2015-04-07T15:35:12","slug":"mysql-subqueries-part-2","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=2105","title":{"rendered":"mySQL: Subqueries Part 2"},"content":{"rendered":"<p>You can use subqueries as column expressions. The most common use of them as column expressions is probably as averages or counts, but you can use any expression that returns a row. Here I want to select only the rows that correspond to apps.<br \/>\n<pre><code class=\"preserve-code-formatting\">\nSELECT \n(SELECT app.name FROM app WHERE app.id = (log.product_id -100)) AS name,\n product_id, COUNT( * ) AS `count`\nFROM&nbsp;&nbsp;log\nGROUP BY name\n<\/code><\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can use subqueries as column expressions. The most common use of them as column expressions is probably as averages or counts, but you can use any expression that returns a row. Here I want to select only the rows that correspond to apps. SELECT (SELECT app.name FROM app WHERE app.id = (log.product_id -100)) AS &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=2105\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">mySQL: Subqueries Part 2<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2105","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2105"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2105\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}