SELECT b_items_p_id FROM public.box WHERE b_id =1 and this is what it returns: {1,3,5} Now on each of these value, i.e., 1, 3 and 5 I want to run another select query: select p_desc from public….
Tag: sql
How to restore postgres 12 generated sql file into postgres 9.6 database
I am trying to restore the database. The database sql file is about 4.5 GB so I couldn’t edit it on editor. I dump the database using following command in postgres 12; But I need the same database in postgres 9.6. For this purpose, I write the following code to restore it It shows the error like this (E…
Fill table (PK column A, PK column B) with table of elements B, where column A does not have B – list pair
So, to me comes Table2 (PK Text) filled with elements FIRST, SECOND, THIRD, FORTH. I need to insert this element to TABLE1 where these elements are missing. TABLE1 +—-+——–+ | ID | Text | +–…
PostreSQL returning only specific value
I’ve got below structure: sample_table code | delivery | end_date | type —————+—————-+————–+—— C086000-T10001 | OK | 2014-11-12 | …
Error with the ID generated when i insert new data in my database Java Derby
i am building an app with a function to insert new Users in the database with Java Derby. Everything is going well, but when i close the app, i run it again and i try to insert a new User (called …
AnnotationException: A Foreign key refering has the wrong number of column. should be 0
What is the reason this error in Hibernate? org.hibernate.AnnotationException: A Foreign key refering com.Otomasyon.entity.Ogrenciler from com.Otomasyon.entity.AlinanDersler has the wrong number of …
PostgresSQL custom sequence
I have a problem with nextval function, I have a custom sequence in my DB called InternalCodes and when i want to make a insert like this: insert into “Membership” (“Name”, “…
Symmetric Pair in SQL with JOIN
I am trying to find the name of students where a symmetric pair exists. There are 3 tables: Edit from your comment: A student is called as being a part of a symmetric pair if the marks obtained by that student in science is equal to the marks obtained by some other student in mathematics and the marks obtaine…
Merge the table based on date and condition
I have following table: In this table type will be 1,2,3,4.. here date and type both are composite key. I need to merge the row based if same date exist to single row and merge based on only below condition and grp col is based on running count of date. Answer Try GROUP BY FIDDLE DEMO Output
SQL query to get data of MCQ question and the answer from two table
MCQ Question and correct answer table name = Table1 Options for every MCQ question and options code table Name = Table2 Table1 Table2 SQL query to get data in the form of – Questions, All 3 options and correct option Answer I am assuming you are using MSSQL as database Use JOINS FIDDLE DEMO Or Output