dont understand, why this not work :C DELIMITER $$ CREATE TRIGGER ‘Reset Pass’ BEFORE UPDATE ON authme FOR EACH ROW BEGIN IF OLD.`password` NEW.`password` THEN UPDATE authme SET `idVK`…
Tag: mysql
Keyset pagination with WHERE & HAVING
I ran into a question that I can’t find a solution yet for keyset pagination: Suppose we have this query: How should we do keyset pagination on that? For a.number only, we can have WHERE a.number < ?; For rating only, we do HAVING rating < ?; If there’re two conditions for where, we can have…
Sort MySQL query in PHP
I’m trying to sort different users ‘points’ by descending order (highest first). But at the moment the query is being returned in order of the user’s ID (order they appear in the database). I’m not sure what is wrong with my code? The user can be in multiple leagues, so it first …
SQL query with Highest value with tie
I am trying to write a query that lists students who have earned the highest total credit in each department. I have to also include tied students in the result. The query should return relation with department name, student name and total credit they earned. It is giving errors and I don’t know how to …
Constant field has to be set MySQL
Attribute ‘Territory program’ is a constant field and has to be set to ‘Territory and Quota Program’ constant in result set, I don’t want to add a new column in table, so how can I do that in my select statement if possible? Also I have a column Status… not distributed R…
How to format date that looks like this (20200326) MYSQL
I have two fields with dates in them. I am trying to format them to look like 03/26/2020 instead of 20200326. So far my code looks like this changed most of it due to my job guidelines so I can’t show you the exact code. Answer Use date_format():
How do I get Django to run a case-insensitive query against my MySql 5.7 db?
I’m using Django 2.0 and Python 3.7. I have this model and manager for attempting to find my model by a name, case-insentively. The backing database is MySql 5.7. Unfortunately, when the query actually gets created, it doesn’t appear Django is doing anything to account for case-insensitivity. This…
Sum unequal and removing duplicates from SQL query results
My base query: It can get me these outputs: Output example: Obs: There is a constraint on (id, on_date) meaning there can always be only one record of a project production on a specific date. Duplicate records, that have the same id, and exist in both dates and have different production values (wanted) Single…
PHP/SQL Find duplicate rows in a column, with the condition that another column is different
I need an SQL query to do the following task: I have two columns. Column ‘foo’ and column ‘bar’. The query needs to return results if and only if column ‘foo’ has different values but ‘bar’ has the same values. For example: If I was to run the query on the above…
Create a stored procedure such that rows with same key are converted into a column
You are given the table tracks, which contains the following columns: received_at: the unique timestamp of the action event_name: the name of the action that was performed at this time anonymous_id: the anonymous ID of a user user_id: the user ID, which can be null This is the mentioned DDL for the problem. T…