Skip to content

Tag: mysql

store function into variable that expects parameters

So given the following example query I want to fetch all documents created in a range of two dates. As you can see I put some calculations into variables because I can reuse them in the WHERE clause. Further those calculations only differ by one value, the month at the end. So the calculation could also be Is…

Combining MySQL Queries to get total amount

I’m trying to combine the following 2 queries. table_A stores a list of available appointments and number_open is how many open slots there are for a specific appointment, in this case 2020-06-30 AM which has 5 open. table_B contains any dates waiting to be accepted and has a different record for each d…

Mysql Join, Count and Sum?

campaign table are the item for sale and on the transaction table are the item sold. I want to count the transaction_id that are made transaction table and sum the total of sold item.. but the table are different.. Here is what I tried: campaign table: transactions table: Answer To get the total payout for al…

Count json tags in sql

I have this json strings And know i want the following output I wanted to do this with a sql query. If you know how to do this, thanks in advance! Answer If you’re not using MySQL 8, this is a bit more complicated. First you have to find a path to a name element that has the value phone

SQL Insert with Inner Join trying to insert into wrong column

I have an existing table of products, and I’m trying to insert new attributes from other tables into my main product table. Here’s my query: The error that I get is: Field ‘product_id’ doesn’t have a default value. I’m not trying to insert into the product_id column, I&#821…