Skip to content

Tag: mariadb

Create view with one row for each column in a table

I have a table that looks like this: I need a view with 3 columns, that has a row for each column in the original table, so it would look like this: The values on the currency column in the view need to be created by me (the EUR, JPY, etc) and are fixed values; I need to get the

How to list 3 largest numbers from table in SQL?

I’m trying to unite two bits of SQL codes and list three largest numbers from it. Here is table relation diagram Query #1: Query #2: My final code shows the full list of all first and second names, simply adding largest number to all of them from orders table. How can I modify it to make it show three n…

How to insert an array value to an existing JSON document?

Given a column containing a JSON document, I can use JSON_SET() to set a key in the JSON document to a value. Supported values are null, true, false, numbers and strings; but I can’t figure out how to set an array. The example in the documentation (for JSON_INSERT(), but it works the same) weirdly shows…

MariaDB, How to copy existing records using insert?

I have a lot of existing records which I want to copy using an INSERT, for example if I have a query: The common key is biDataset, the primary key in this table is biPK which is auto incremented on each insert. Here is the table structure: What I want to do is copy all the records that exist where

SQL MAX() function seems to truncate results

I have the following basic 3 Table Structure in mariadb/mysql. This simple SELECT returns incomplete records. I reduced the output of all follwing examples to a single dataset to avoid unnecessary clutter. The IP_LONG column is missing the follwing for example… My guess is, it has something to do with t…