Category "sql"

how to create a user in postgres to connect to nodejs?

It is my first time using postgres and I am trying to use it with node. I installed postgres in Ubuntu and created the user admin sudo -i -u postgres createuser

Avoid incrementing primary key if insert is not successful?

I have a 'locations' table as follows: Using an API, if I send a valid record, the table will start normally with index 1. If I send something that won't be ac

error in migration with legacy database in Django

I'm working on creating a filter in django where the options displayed are coming from a new column in the database. It turns out that this column was created d

StackOverflowError when connection to aurora using mariadb java client

When connecting to an aurora db using the mariadb java client (version 2.7.5) i am getting this error (I only put the first few lines because the entire stack i

How can I select few columns with MAX(column) from several grouped columns?

My table has a lot of columns, I didn't list them all at here. But the selected columns are like below: product_line test_port rate1 rate2 test_stage finished_

Error mysql syntax use 'declare pfee int default null;',check the manual that corresponds to your MySQL server version

delimiter // create procedure payFees(in deviceid int, in fee int) begin declare pbalance int default null; declare ptype varchar(2) default ""; dec

Missing dates for specific identifiers without adding extra dates when this identifier is no longer in the database SQL

To put the problem in words, I have a massive table which includes subscribers and data for every day. If the subscriber no longer exists, then they will have n

How to work with column containg array in H2 database to get n 1 row

I am new to H2 database. I have 3 tables in database for example, table t1 : ID desc something condition_id 1 EN 142868 151508 XYZ [4686, 4687] table condition

Slow Query in WooCommerce, what to do?

I have written a Plugin that displays the sum of all purchases of all customers of the last year, ordered by the sum (Customer who bought the most is on top). I

How to map nested freezed union classes to drift/moor sql tables?

I need to save this Objects into a SQL/Drift DB, how can/should I design die Tables/Rows for an efficient mapping? Here is are examples of a (deep)nested union

How to delete a record depending on the following record

I have a table with the following columns Car | User | Location | Time | Type The type can be 'OUT' if the user's request to rent the car is accepted

In SQL, how do I filter a parent with its child records if either satisfies a condition

I have the following table as example. I want to retrieve only the records where the ScheduleDate is smaller than 2022-01-03 (Jan 3, 2022) for either the parent

How to Join two tables and update a column?

I have two tables as below TableA TableB ID1 ID2 ID1 ID3 1 X 1 X 2 NULL 2 A 3 (NULL) 3

How to get tally of unique words using only SQL?

How do you get a list of all unique words and their frequencies ("tally") in one text column of one table of an SQL database? An answer for any SQL dialect in w

SQL Developer Language won't change

I have an issue with SQL developer where the GUI language won't change as it shows here Now I have tried the solutions where I added the following to sqldevel

SQL Group/Orderby

I have a set of records in a db table like this. The thing that logically links these records is guid1 and guid2 but not all records in the table have a full re

MySQL, count values by key

I need to count values on a table accordingly with their presence or missing. With a clear example consider a table with 2 field: +-------+---------+ | K |

MySQL pagination with limit returns the same values

I'm trying to do pagination, but the SQL query returns the same values on different pages. I show them the queries and the results, and it shows that there are

SQL Server 2017 undetected deadlock issue

The problem is: BEGIN TRANSACTION SELECT TOP 1 q.* ) FROM [QTable] q WITH(UPDLOCK) WHERE <some condition> ORDER BY <some columns&

SQL: select all depending nodes from a list of parent

let's take a table called users like this id name ... path 22 John ... 2/8/11/22/ 23 Mark ... 1/3/9/15/21/23/ where the path rapresents the hierarchy parent-c