Actually I have: CREATE TABLE public.user( id BIGSERIAL NOT NULL, nick VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, born DATE, joined DATE, tags text[] ); I want to choose best …
MySQL how to solve One-to-one relation
I have a One-to-One Chat implementation with MySQL. The goal is to got for one user all unique Conversations with the last message. Even I’m using MAX on the primary key and group by 2nd column MySQL …
“Hive” max column value from multiple columns
Hi: I have a situation where I need to find the max value on 3 calculated fields and store it in another field, is it possible to do it in one SQL query? Below is the example One way I tried is to calculate Personal_Income, Share_Income, Job_Income in the first pass and in the second pass I used but this
Update key of object inside array of objects in jsonb column
I have a jsonb column called data. It is deeply nested and there’s a key which’s value is an array of objects: As you see, there are different forms of “b” key. My goal is to update all rows with “b:” and “b_” keys and set them to “b”. Answer This an…
How to export Excel data from different sheets to SQL-SERVER Database?
I am new in Excel VBA and SQL. I have managed to create a macro button and push Excel cell data to SQL server tables. However, I am a bit puzzled: How can I take Excel cell data from different sheets and then push them to different tables in SQL Server database? (Currently, I have 3 sheets – Customers, …
MySQL – save base64 encoded data to storage drive
I’m building an app that uses a temp table where chunks of a file are uploaded to, then a stored proc is called with a function that reassembles the file into the right order. I’m just wondering if there’s anything in SQL that would allow me to outright save the reassembled file to disk (eg.…
How to insert data with custom enum type from a csv into an existing PostgreSQL table
I want to insert data from a csv file into an existing table on a PostgreSQL database – let’s call the table automobile. One of my field is a custom enum – let’s call it brand. When I try to import records from a csv file with DataGrip built-in feature I got an error message: Yet in th…
Invalid Syntax Near The Word “FOR” (but no FOR)
I’ve written a piece of SQL which works perfectly inside MS SQL studio 2017 with no problems. I have brought this over to SAP B1 and get the error as below: Invalid Syntax near the keyword “FOR&…
converting varchar to binary in mysql?
I have the following data in a table like so: The data looks like this: I want to convert this into binary. How is it possible? I tried these queries but getting the same result: How to do this? My expected result is should be like this: Answer Since the accepted answer is unnecessarily complex, here a concis…
In a one to many relationship, is it possible to do a query for parent based on if they have certain children without using count and group by?
Say my the schema for these two tables is as follows: owner —– pk owner_id int owner_name text possession —– pk possession_id int possession_name text fk owner_id int Now, say the the records …