Skip to content
Advertisement

Tag: postgresql

How to update a table if values of the attributes are contained within another table?

I’ve got a database like this one: I’m trying to create a query that would enable me to update the value of the status attribute inside the incident table whenever the values of all of these three attributes: tabor_vatrogasci, tabor_policija, and tabor_hitna are contained inside the izvještaj_tabora table as a value of the oznaka_tabora attribute. If, for example, the values

PostgreSQL: FOREIGN KEY/ON DELETE CASCADE

I have two tables like here: So the logic is simple, after user removes all book under category x, x gets removed from cats, i tried method above but doesn’t work, after i clean table book, table category still populated, what’s wrong? Answer A foreign key with a cascade delete means that if a record in the parent table is

PostgreSQL – repeating rows from LIMIT OFFSET

I noticed some repeating rows in a paginated recordset. When I run this query: I get: Next query: I get: Why does “foo” appear in both queries? Answer Why does “foo” appear in both queries? Because all rows that are returned have the same value for the status column. In that case the database is free to return the rows

Query using ILIKE with IN

Is it possible to run a query using ILIKE with the IN function? For example: I want to run the results returned from the nested query through the ILIKE function. Is there a way to do this? Answer Can be simpler: You can check the resulting query plan with EXPLAIN ANALYZE. You may need to add leading and trailing %

Advertisement