Skip to content

Tag: mysql

SQL – Naming conditions for filtering

I wrote MySQL query to filter and count items in a table by date and now a need to get results like: +—–+——————–+ | cnt | creation_date_date | +—–+——————–+ | 90 | …

Get executed sql statement in pymysql

I am executing a query that is invalid, but I’d like to be able to see exactly what the query is being executed by pymysql to debug it. Is there a way to do something like: Answer As per the documentation, you should be able to do: This read-only property returns the last executed statement as a string.…

How to use GROUP BY which takes into account two columns?

I have a message table like this in MySQL. Messages in a recepient’s inbox are to be grouped by thread_id like this: My problem is how to take recipient_read into account so that each row in the result also show what is the recipient_read value of the last message in the thread? Answer In the original q…