I have two simple tables in SQLITE3 (family bonds): “persons” (id, fname, lname) “relationships” (parent/child) I would like to get each grand children along with all their grand parents (from 1 to 4 of them depending on the grand child) so that 1 row result = Thanks to Caius Jard, I’ve been able to get each child and its grand
Tag: inner-join
SQL INNER JOIN of sum distinct values
I have 3 tables called musics, singers and playlistInfos. I want to get Top 10 listened England musics.What kind of sql query help me? SELECT * FROM musics m INNER JOIN playlistInfo p ON p.musicID = m.id INNER JOIN singer a ON a.id = m.singerID GROUP BY p.musicID ORDER BY p.listened I try this one but I did not get
Trying to join two tables together to have the unit_price vary based on the day
I have some code drafted but I’m not sure how to finish it, or if it needs more work. It looks like this. Everything looks good, but how do I get the price to be based on the given effective date? The given effective date is 01/01/2021. I was thinking something maybe like this for the where: I’m not sure
SQL inner join on column A and compare values in column B
I am sure or maybe hope there is a simple way to do this. Below is my latest attempt. The query should return only one row, but I get 31. Query: `select distinct a.[EC CERS], a.[EC Tank ID], […
What is the issue in below sql query? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I am beginner in sql. Anyone please tell me the problem of my customised query. Error Code: 1241. Operand should contain 1 column(s) Subscription table
mysql order by field row display even if empty
I’ve two tables( bom and bom_parts). Need to inner join and display stock_deduct,GRN_id,part_id fields. Table 1 (bom): Table 2 (bom_parts): MySql query: Query Result: Expected Result: Even if the part_id field is empty in this case 8, 6, I just want to display the part_id with the stock_deduct field as 1 in the result as mentioned below. Stock_deduct GRN_id part_id
Select from multiple tables with group and join
i have 4 tabels drinks, opskrifter, ingredients and stock the tables consist of drinks drink_id name beskriv glas image alcohol opskrifter drink_id ingredient_id quantity ingredients ingredient_id name stock ingredient_id name i want a query to select drinks that can be made in opskrifter of the ingredients in stock. i have this working, but it only returns drink_id. I want it
SQL – cartesian product of PARTITIONs
There is a really complicated query, which I cannot wrap my head around alone. In the queried table there are 5 columns: PK_ID, which is the unique identifier of the value, ID, which connects the aggregated values in one group, the count, which says, how many value groups should be aggregated (if there aren’t enough, the group with such ID
Update columns based on calculation
My table looks like this: I have a list of id’s connected to datestamps. I can manage to calculate the difference between their latest and first entry as follows: However, I am unsure how I can update my table to reflect these calculations. What I want is the following: Answer In MySQL, you can self-join: I would not necessarily recommend
Query slow in Web App, but fast in command line
I am need to retrieve records from two tables which are linked by a third. Session content doesn’t contain any information I need besides the keys to link the other two tables. I am currently using these joins: It only takes 50 ms in SQLite DB browser, but takes multiple seconds of buffering when I call the related API endpoint.