skip to Main Content

Optimize MySQL query using range and group by on large table

My table structure: CREATE TABLE `jobs_view_stats` ( `id` int(11) NOT NULL AUTO_INCREMENT, `job_id` int(11) NOT NULL, `created_at` datetime NOT NULL, `account_id` int(11) DEFAULT NULL, `country` varchar(2) COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), KEY `IDX_D05BC6799FDS15210` (`job_id`), KEY `FK_YTGBC67994591257` (`account_id`), KEY…

VIEW QUESTION

Multiply output of subquery (MySQL)

I'm trying to multiply the result of a subquery with a field from the 'main' query. See the following example: Table: subscriptions id title price Table: users subscription_id SELECT subscriptions.id, subscriptions.title, (select count(*) from users where users.subscription_id = subscriptions.id) AS…

VIEW QUESTION
Back To Top
Search