Skip to content
Advertisement

Tag: postgresql

simplifying postgres queries

Note: Asking to improve the working code. My data column is as follows In the above data, I want to set available to false and price to zero. To do this I Am using the below code. My question is it possible to update both values in a single query? Thanks. Answer Sure:

Multi-column IN/ANY postgres query

Sample table schema: Requirement: Fetch rows that match any of the tuples (col1, col2) presented in an array. SQL: I want to write this query in Go using the “database/sql” package with “github.com/lib/pq” driver, and that is where I am facing the problem. I can easily do this for single column IN/ANY query. for example, the following query can be

How to insert result of select query (with default if return no rows) as part of Postgres Function?

For my Nextjs website, I am configuring the backend to automatically add user information to a public.profiles table whenever a row is inserted into the auth.users table (automatically done through Supabase’s authentication). I have a public.college_emails table that contains the names of over 1700 colleges and the email tag associated with them. When a user creates an account with their

Multi-column Index on a filter & sort by query

I am executing an query of type: Query: Table: entity also has an index (Btree) on it as such – Index: But it seems that this type of index is of no use on the above query. Can anyone suggest what kind of index would better serve this type of use-case? Some Additional Information – The Table is quite huge,

How to select records from a Postgres table using an ORDER BY statement on a jsonb column that points to another table

I have two tables, characteristics and students. characteristics students The characteristics table has three columns where the id column is an auto-increment field. The name denotes the name of a specific characteristic and the value indicates the respective information about the characteristic. The students table contains detail about each student. The character_value field in the students table is a jsonb

I can not convert the data to the required form

Hi hi I have a Nodejs server and I am using PostgreSQL, the bottom part of my database. How can I select data and represent it like this (in one sql query): I wrote a request but it is far from what I need: Answer You can use a cte to first build the question JSON data, and then aggregate

Advertisement