Skip to content
Advertisement

Tag: postgresql

SQL database design: many to many relationship between ‘accounts’ and ‘transactions’ tables such that a transaction can have ‘from’ and ‘to’

I’m trying to create a many-to-many relationship between two tables: ‘accounts’ and ‘transactions’, but with a catch. Every transaction must be related to two accounts, but each of those accounts must be specified as either the sender or receiver. Likewise, each account should relate to all the transactions they are involved in. Is there a best practice database design pattern

PostgreSQL / express rookie – create new table or just a new column in existing table? [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 This will probably get closed for being opinion based but hopefully I can get a comment or two. I’m building a social media app (Express/Postgres/React)

PostgreSQL group by column with aggregate

I need to group by id and select the task with min/max seq as start and end But this results in But I do not want group by seq Answer One method uses arrays: Another method uses window functions with SELECT DISTINCT:

How to escape several with in the query?

I need to refactor my query, but I have no idea, how to do this. I can see several duplicates of using the same logic, but I continue to repeat this manner of querying from query to query, and I feel, that this kind of querying becomes my main frame of thinking of SQL and I don’t want this. Could

Using update inside of PL/pgSQL

To begin with, I am a newbie to SQL and PostgreSQL. It might be a silly beginner’s mistake. ^This isn’t working provides me with an error SQL Error [42601]: ERROR: syntax error at or near “update” Where: PL/pgSQL function temporary_function_for_getting(text,bigint,json) line 13 at RETURN QUERY . The update query works fine by itself not sure what i am doing wrong.

Advertisement