Can you share expected output ?
Hi, isit possible to add data to mysql database from telegram bot ?
What issue you have ?
Hello, any way for detect a change in a table?
is there any id in the table ?
How can I know when a query was running by reading mysql slow log?
those timestamp are when it was written to the log right?
how can i know when it was starting to run?
id, phase, count(*) over (partition by id, phase) as cnt
from tablename
order by id,phase
Definitly, yes, possible
id, phase, count(*) over (partition by id, phase) as cnt
from tablename
order by id,phase
this is wrong query
Can you elaborate ?
no
Whats the point in wrong query then.
Pity🤦
DISTINCT and aggregates canot be in the same query, aggregates cannot be without group by
Who told you
Go and execute the query you will get the expected result
That is true.
Actually i had executed the query with expected result and then pasted the query here
Swapnil this is expected output
I have tried below and is working fine as expected
— create table
create table test (id int, phase text);
— Inserted demo records
insert into test values (1,’A’);
insert into test values (1,’B’);
insert into test values (1,’A’);
insert into test values (2,’A’);
insert into test values (2,’A’);
insert into test values (2,’A’);
insert into test values (2,’C’);
insert into test values (2,’D’);
— Working Query
select id,phase,(select count(distinct phase) from test a where a.id=b.id) as phase_count
from test b
order by id
Output:
id | phase | phase_count
—- ——- ————-
1 | A | 2
1 | B | 2
1 | A | 2
2 | A | 3
2 | A | 3
2 | A | 3
2 | C | 3
2 | D | 3
What issue you have ?
Trigger?
Thanks
@last_entry in mysql
@last_entry in mysql
SELECT MAX(id) FROM mytable
or
SELECT * FROM mytable ORDER BY id DESC LIMIT 1
is there any id in the table ?
But go on about the id
I’m preparing for the interview on SQL
select * from table
where date < (select data from table where date = now())
order by desc limit 1
Time: 2022-06-25T23:22:12.134584Z
User@Host: user[user] @ [1.1.1.1] thread_id: 12631872 server_id: 34534534
Query_time: 5441.241800 Lock_time: 0.000278 Rows_sent: 17930 Rows_examined: 484011894
SET timestamp=1656199332;
query….
those timestamp are when it was written to the log right?
Time: 2022-06-25T23:22:12.134584Z
User@Host: user[user] @ [1.1.1.1] thread_id: 12631872 server_id: 34534534
Query_time: 5441.241800 Lock_time: 0.000278 Rows_sent: 17930 Rows_examined: 484011894
SET timestamp=1656199332;
query….
those timestamp are when it was written to the log right?
Yes
how can i know when it was starting to run? not to log