The scenario is a set of tables that contain data related to markets and goods produced at those markets. In the basic example below, you have Ice and this produces water. I have a SQL query which works well and is performant (5ms~). It calculates the stock of Ice required to produce X amount of Water (they are both goods)
Tag: mariadb
DBeaver adds single character when auto-completing a table name (for MariaDB databases at least)
DBeaver adds a character (the first letter of the table name) when auto completing table names, resulting in a query that looks like this: As far as i can tell, it works, and has no impact on the query/results… can anyone enlighten me as to what it (the c) is? Answer “C” is an alias name of the “countries” table.
MySQL – Show the restaurant name and items where price is over a certain value
I have two tables: I am trying to get the restaurnat name, item name and price where all the restaurants’ items have a price higher than 10. Examaple result: restaurant item price The King Fry item 1 12.30 THe King Fry item 2 13.00 The King Fry item 3 10.60 All the items listed on their menu are > 10
How to return rows containing decimals in a range
I have the following table: Rows Decimals First 1.1.1.3.2 Second 16.1.1.1.89.1 Third 3.1.1.1.177.2 Fourth 1.1.1.1.178.3 I only want to return the rows where the second to last decimal is between 0.7 to 0.94 (inclusive), but all the other numbers can contain any value. For the above table, this would be only the second row. How can I specify my query
modify the data of column while copying the data of column from other table
In mysql, I am trying to copy the data from one column to other column of different table. I have used the below command to achieve this. data in old column is data:test data in new column should be {“payload”:”data:test”} As of now when I used the above insert command, it just copies the data as is from old column,
MySQL – How to use JSON_EXTRACT to get values between two indices
I am trying to extract values between 2 indices in a JSON array using mysql JSON_EXTRACT. This query will smoothly return 20 as result. But if I want to get all the numbers between, say, 1st and 3rd indices, how do I query it? I was expecting something like: which will return 20,30,40. But not working. How do I achieve
Can I get two count results in a query?
I am using MariaDB. I want to have two count results in a query. The first query is: Next is: What I want to get is: How can I combine them? Answer The usual way is to make a Case..When statement that is one or zero for the desired condition and then SUM it, not COUNT it.
SQL Query for the Last 6 Months of users registered
I have created a query that shows the last 3 months of users registered to my site and currently have it grouped by day to show on a line graph. I would prefer to show it Grouped by Week on the line graph but have been unable to change my query successfully. Here is what I have written so far:
weekly event select into file with different filenames depending on the variables(MariaDB)
I’ve always been a silent reader here until now. Now I would like to ask for your expertise and post my ver first question here. I have to achieve the following task on a weekly basis in my MariaDB via Events: Every Week on Saturday night at midnight, i want to save the results of a certain view in an
How to create pivot table entries for all of the rows available in two separate tables in MYSQL
I need help to create pivot table entries for all of the rows available in two separate tables, basically, I have two separate tables as services and plans as below plans table id name description 1 plan one description for plan one 2 plan two description for plan two services table id name 1 service one 2 services two and