I have a table defined like this (MySQL 5.1): Sample dataset: I need to show records matching a certain criteria (lets suppose lastname = ‘Santucci’ ) only if the number of records is greater than a certain defined limit (lets say 2). I tried in various way without success the most promising form …
Tag: mysql
put on duplicate key update in MySQL
let’s say i have 2 tables table shipping id origin order_id createdAt product_id amount 1 1 11 2020-12-22 234 2000 2 1 11 2020-12-22 235 3000 3 1 11 2020-12-22 236 4000 4 2 12 2020-12-22 236 3000 5 2 12 2020-12-22 235 2100 6 3 13 2020-12-22 236 2200 7 3 13 2020-12-22 239 3400 8 4 14 2020-12-22
MySQL – select distinct value from two column
I have a table with the following structure: How could I make a select statement on this table, which will return some rows of this table, where in each row, a specific id appears only one, indifferent on which column it is specified? For the above result set, I would like a query that would return: To give a…
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-joi…
Change column value if date is older than 1 hour in mysql/mariadb?
Say I have below SQL table: Basically I want MySQL to check the Date column every 3 minutes and if Date value is older than 1 hour, I want to change Status to Offline. Can we achieve such thing in SQL? Alternatively if there is easier solution in Django python, I am open to use that as well. Answer I
Create a table in a trigger and compare it
i have 4 tables and i want to create a trigger that it declares a table and store it all in that table so it can be compared latter. In here are the tables that im using. But now i have a trigger that after insert on orders it inserts on transactions. My objective now its to create a trigger
How can I achieve a Cartesian Product for all distinct entries of two fields within the provided sample data without using a Cross Join (MySQL 5.6)? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question Here’s a sample data set: Specifically, I want to get the Cartesian …
How to calculate the percentage of a nested table architecture in mysql
My current tables architecture is the following: Card Table ( Parent table: Card) Each card has one or many lists (Second child lists) Each list has many tasks (third child tasks) Whenever the user fill a task it will be filled in a separate table called (user_tasks) So if you want to imagine it it’s li…
I get an error “Error converting data type nvarchar to real.”
The code which I have is below, can you please inform me where the issue might be so we can drop the price by warehouse ID with 7%? Answer As you are not assigning any value to @Price in the C# code while your Warehouse Id and the Discount rate are subject to be assigned by the end-user, I recommend
Which cars have been rented together how many times? Which one is more easy to do MySQL or python?
I have a project about github but I represent like rent a car db for better understanding. I must find which cars have been rented together how many times from db. I have a 2 table: rent and car. I want to like this type of return I tried some queries to find this but I can’t. Also, I think