Skip to content

Tag: mysql

Query to check if MySQL database is connected

I am wondering if there is a best practice or standard query used to check if a MySQL database is still connected? I was originally thinking of performing a simple search in one of my tables, which will confirm if the database is still there. Just wondering if there is a better approach. Answer No need to act…

join two tables where unique id is 0 in other table

below are the two tables 1st is media_taxonomy and 2nd is media_taxonomy_map to join media_taxonomy: media_taxonomy_map: here is my sql query here is the result: BUT, I also want the rows in the joined table where media_taxonomy_id is 0 in media_taxonomy_map table is this possible? Answer I am guessing that y…

How sum values in days intervals MySQL 5.7?

I have a server with MySQL 5.7. I have two tables. First one t contains creating dates for each id. Second table t0 contains profit records day by day for each id. I want to get columns with sums of profit for first and second 30 days for each id as well as for the first day. This code runs

Mysql Json extract with conditional filter

I’m trying to query some json data through a filter. Given a json array like this: I’d like to select all the rows which have as country name ‘France’ and a value greater than 10 as ‘people’ ONLY in objects which have the property name set to ‘France’. Would it …

How to change column charset, set as not null and add a default value?

The column contains some rules such as not nullable and character_set_name is latin1 and I should write a query to update only the character_set_name. field: name type: varchar(255) null: NO default: JACK character_set_name: latin1 Is there any way to do this in one query? if I run only the first query, &#821…