@bikashkatwal count() is an aggregate value. It is counting the items in the table. To increment the value you need to add a record to the tmp table.
Feb 11, 2020
4
Level 3
update temporary table
CREATE temporary table tmp (
id INT ,email VARCHAR(255),
first_name VARCHAR(255),
last_name VARCHAR(255),
total_halls VARCHAR(255),
override_membership_price VARCHAR(255),
total_amount VARCHAR(255),
gst_amount VARCHAR(255),
subscription VARCHAR(255),
expires_on DATE
) AS
SELECT u.id,u.email,
u.first_name,
u.last_name,
u.expires_on,
u.subscription,
u.override_membership_price
FROM halls.users u
WHERE u.expires_on=DATE_ADD(CURRENT_DATE(), INTERVAL 1 MONTH)
AND u.activated=1 AND u.subscription='yearly';
SELECT * FROM tmp t;
SELECT t.id,count(*) as count
FROM tmp t INNER JOIN halls.halls h ON t.id=h.user_id group by t.id;
I have to update count fetched SELECT t.id,count(*) as count FROM tmp t INNER JOIN halls.halls h ON t.id=h.user_id group by t.id;. How can I update the tmp table with count(*) ?
Please or to participate in this conversation.