Skip to content

Tag: sql

MySQL customized exists query performance

Because of using Hibernate, I cannot write a JPA query using exists like this (I translated it to pure SQL query): So I have to write an alternative query to check existance of activated accounts. After reading several suggestions on this website, I see a replacement: My question is: Is this bad for performan…

How the SQL query with two left join works?

I need help in understanding how left join is working in below query. There are total three tables and two left joins. So my question is, the second left join is between customer and books table or between result of first join and books table? Answer The second join statement specifies to join on s.book_id = …

crosstab in PostgreSQL

I have the following tables: and How can I query the database so that it returns the table where n ranges over the rows of the table sensor and ‘abbrv $i’ is replaced by the corresponding value in the table sensor? The following query works up to a certain extent: I need to know how many rows ther…

What’s wrong with this PL/SQL Trigger?

I have this table, and I want to create a trigger on Magazine, that verifies “after insert” if the name of the Magazine inserted is either Vogue or People. If it’s not one of them, it gets deleted. Table: MAGAZINE (ISBN, MAG_NOM, PRIX_Mois); My trigger: But the problem is my teacher told me:…