Skip to content

Mysql query dosen’t provide the result needed

I’ve been trying to figure this one out for days but can’t come up with a solution. Here are the table schemes. This is my current query. The problem is that the query returns as long as there is one article with status bigger than 1. I need a query where all the articles of that order have a stat…

Select based on multiple ID’s in the same column

I have two SQL tables already built (not by me) : One table that has all the ingredients with ID’s assigned to them : and the second table that has finished products that have reference to ingredientID in the ProductIngredients column but no the product name and they are built like this : If they don&#8…

sql query for grouping column into row

So, I have table like this and I want to make query so the result is like or I have try to use GROUP BY but I dont know how to get the slot number. Please help, thank you! Answer With conditional aggregation: See the demo. Results: And for the 2nd case use group_concat(): See the demo. Results:

Need Combined SQL Query to Update 2 Tables

I am having 2 tables. Table1 and Table2. I need to update these 2 tables based on some conditions. The SQL select query from Table1 will return multiple records, let’s name it as SQLQuery1 From SQLQuery1 results returned I need to loop through each record and execute another SQL query from Table2 which …

How to find how many times X appears

Learning SQL using SSMS and I have been given a database and a 32 questions. I am working my way through the questions and got suck on a question of “How many people live in each city?” I know how to …