I want to create two tables. practice has a AUTO_INCREMENT attachment and is a PRIMARY KEY. continued has the id entity continued_id which exists as a FOREIGN KEY that references practice(user_id). Mysql executes the code below fine until line 19, where I receive the 1364 error, stating that continued_id has …
LIMIT and Contains in a single JSONB Query
I have 2 queries that separately run perfectly: This one limits the results: SELECT jsonb_agg(elem) as data FROM ( SELECT * FROM file_data, jsonb_array_elements(file_data) a(elem) LIMIT 3 ) …
MariaDB : an INSERT…SELECT with empty VALUES too
I want insert data from another incomplete table, so some values must be empty in NOT NULL fields. For example, I have two tables : people and peopleTemp. In people table, I have a lot of fields : permit_number, first_name, last_name, gender, tel, etc. In peopleTemp table, I have only permit_number, first_nam…
Find rows based on nested key in jsonb array
I have a jsonb column in Postgres 9.6 that contains JSON arrays of the following form: [ { “courses”: { “course-1”: { “graduated”: false }, “course-5”: { “graduated”: true } } }, { “…
SQL how to convert array to values for use in IN clause
Working in Postgres SQL: My query argument comes in as a comma separated string: ‘ABC,BCD’ I am trying to construct the query below, but getting an error: ERROR: Operator does not exist: character varying = text[] My question is how to convert ‘ABC,BCD’ to a list of values to use in th…
C# SQLConnection.Open() hangs, with no exception
I am using C# in Visual Studio 2019, with Xamarin.Forms, and SQl in SSMS 2018 and have the below code (where [] is used to replace unneccessary information) When I run this, it hangs indefinitely at connection.Open(). Debug mode continues to run and appears to move on from Connection.Open(), but never reaches…
Is it possible to append a csv/txt file into a SQL table?
I have a table that i have already designed in SQL. My goal is to create a stored procedure to append data from a location into this table. It is a large data set (over 255 columns) so i cannot …
Group rows by datediff and then use diff function
I have table in PostgreSQL with timestamp column created_at and integer column user_id. Each row represents some action from user. I need to calculate average user session length. Session is defined as group of actions with time difference less than 10 minutes. When there is difference 10 minutes or more betw…
Return Most Recent Record group by 2 ID fields
I need to display the current status of a part (‘approved’ or ‘not approved’) I am setting up the status table as MaterialNo, ToolID, Status, Asofdate the idea is I may have several tools approved and several not approved. I want to be able to see the most recent status for each tool b…
How to select count between start to (start+length) [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question How the following result appears when creating a table as above. This is the result of count…