Skip to content

Tag: postgresql

What is the bad in running multiple commands in the same query

I am using Sql-Server and Postgresql, usually when I need to run multiple commands, I open a new connection, and foreach needed query task I run a command (inserting 1000 rows, for example). Is it bad if I run multiple query commands in a single command(queries separated by comma) vs previous behavior? Answer…

join without a join in PostgresSQL

I have code with the following psql query that I try to understand (It was simplified for the question): Is it the same as doing a join, or am I missing something here? Answer You are doing an old school implicit join. This is the syntax used before the ANSI-92 SQL standard which started recommending explicit…

How to select size of json array in postgres?

I’ve been fighting this for a long time, but I am not able to construct a query, which would select (and preferably also order by) a count of items in an array. I do have table data like this: And what did I try… also But it sais I’ve tried a lot of different formats but coming from the MS

How do I select just mutual rows in SQL?

I have a table with a source_id and destination_id and a message and I want to group messages together. There can only be one message between a given source_id and destination_id, but I only want rows that have a mutual response for a given ID (say id 1). In the following examples, I want rows #1, #2, #4 and …