I’ve got three tables: products(product_id, product_description) keywords(keyword_id, keyword_name) product_keyword(FOREIGN KEY(product_id) REFERENCES products(product_id), FOREIGN KEY (keyword_id) …
How do I order categorical data in SQL to match a list of names?
How would I order a column of categories based on a specified (and ordered) list of just those category names? For example, let’s say the names of groups a, b, and c, are listed in descending order based on their respective group mean blood pressure as [b,a,c] (with b having the highest mean blood press…
Bigquery Full Join ON multiple conditions
I want to perform a Full Outer join on two tables with multiple conditions to result all the matching records along with unmatched records from both tables. Tbl1 is a bigger table with 21 M records and Tbl2 has 5k rows, like the example query below. But the outer join cannot be performed with OR conditions be…
MySQL – Joins and Subqueries [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question IR…
SQL Server performance optimization
I have table to store files. I store SHA256 hash in a column to uniquely identify a file. Before inserting new file I check for duplicate file using the hash and if it exists already I don’t insert. For example my query can be: Right now there are only a few hundred files. When this number grows to a fe…
Aggregate Function Error With Basic Query
My database is based on a cinema, I am trying to make a query which displays the number of tickets purchased for each movie screening. The tables involved in this query are Bookings, Screenings and Movies. Here is the Bookings table: The Screenings table: And the Movies table: I have so far managed to get the…
Generating sequence numbers
I have table A I have table B How do i get values ‘304’, ‘305’….n in B.number column if any new values comes in table A by keeping table B static(i.e keeping the old values in table B unchanged) Answer This should work, as you’ve posed the question. But this is a strange th…
Problem in creating new table ORA-00906: missing left parenthesis
Here is my instruction : it works on my friend computer ! A ORA-00906: missing left parenthesis Any help ! Answer Please make sure all the “varchar” fields has a length defined. In your second table, it says: date_rdv VARCHAR NOT NULL, which I believe causing the issue, so try to change it into da…
Is it possible to update or insert if not exist in MySQL using where-in clause without primary key?
Below is my database table. User id role type name 1 1 1 John 2 2 1 Doe Below is my data: role = 1 type = 1 name = HelloWorld role =…
Setting up a complex query in MySQL [closed]
Basically i have this kind of database: user: id username password name surname photo: id url upvotes user_id(foreign_key) pair: id user_id(foreign_key) photo1_id(foreign_key) photo2_id(foreign_key)…