Skip to content

Tag: mysql

SQL Update One Table If Record Does Not Exist In Another Table

The above works to give me all the customer accounts that have no invoices. It takes a long time to run, but I’m not concerned with the speed. I will likely only run this a couple times a year. What I can’t get right is updating a record in the customers table when the account has no invoices. I h…

Why did I sum the wrong result?

I’d like to have an advice for this SUM that doesn’t work as expected. I have to SUM data from the same day and display it in a table. I did a query like this: This is the ‘simple’ one and it displays every single row, I have to put a SUM in it to make it show every day

MySQL 8 create new user with password not working

I am using MySQL for several years and the command for the creating the new user till the MySQL 5.x version is as follow: Recently I installed the MySQL 8. In that, this command is not working. It is throwing following error while firing above command: Is there any change of syntax in MySQL 8? What is the cor…

Suggestion for a contact management database design

I am currently designing a contact management database for a chamber of commerce. The goal of the database is to store all the person (except our own staff), all recorded companies (regular companies and member of the chamber), addresses of the person and companies, tasks that the staff are currently responsi…

MySQL script triggers Error #1241

I have the script below, which is supposed to get a price for an array of ID’s that has been provided. But it needs to get 1 price per ID, and the tricky part is, that I want to have the ability to have scheduled price updates. This mean that it needs to take the price that is <= UTC_TIMESTAMP

MySQL aggregated sum of JSON objects

I have created new table and having details as JSON datatype. I tried to get the aggregated sum of all records. I can able to get the each values but I don’t know how to get the sum using group by …