I have a model questions that has many tags through another model question_tags. I am trying to write an api endpoint that returns a list of questions and for each question a list of it’s related tag’s name and id. I’m currently using; But this runs a separate db request for every question in questions is there an alternative that
Tag: database
How I can update one to many relation in Postgres?
Here is my first table question. Questions have many options, so I referring every option row with question_id Now, How can I update both tables in one query? I building an API. The below-given output is for request. The request will response with question details and options for the question. I am able to update question but questions have many
H2 database – Update from select sets out-of-date data after h2database upgrade to version 1.4.198
We have a simple counter in out project database. Until now we were using version 1.4.197 of H2 database. Executing below example snippet with this version always imply counter to be 5000. Upgrade to version 1.4.198 or above makes below code returning inconsistent results, usually between 1500 and 2000. My assumption is that the select statement from below SQL is
Conditional Postgres Query
The PG table looks like this: I would like to write a query that only lists rows in which Name has a ‘Type A’ record but not a Type B record. This is the result I am hoping for: Answer You can use a nested select:
How to find every genre from an artist in a music database in MYSQL?
So I’ve got a database with 4 tables: artist, genre, track and album. Track table points in a many to one way to Genre table, and so on with Track to Album, and Album to Artist. Suppose I want to find every genre that ‘John Coltrane’ plays, so I thought about saying But this just gives me i.e. ALL genres
Select query to group records in output json using BigQuery
I have a datetime partitioned table in BigQuery with a schema like: So, if I do a SELECT * FROMmy_table`, it will generate a JSON with a structure like: And that format works well in most of my use cases, except for one. So, if I wanted the id’s of all the inverters i would do But I also need
How to read double signups for a class in two separate databases without subqueries? SQL
I am using MySQL for an intro to databases course. We are currently practicing using aggregations and joins to create new relevant columns. I have a class table that contains information about classes such as the class id, name, code, etc. I also have a ClassStudent table that shows all students that are signed up for a class as well
Why store whole records in audit tables?
I worked in several companies and in each of them audit tables have been storing full snapshots of records for every change. To my understanding it’s enough to store only changed columns to recreate record in any given point of time. It will obviously reduce storage space. Moreover I suppose it would improve performance as we would need to write
3 Dimensional Database in SQL [closed]
I have a question. how do I store 3 dimensional data? This is an example. Every user should fill this field. 2 Dimension
My SQL query states that my query does not include the specified expression as part of an aggregate function
I can’t seem to get my SQL code to work and I have gotten it to accept the EventRequest.eventno statement however there is another error stating that ‘the query does not include specified expression ‘…