Code: UPDATE COMPANY SET id=’21’ WHERE id=’20’; Error: SQLException: Duplicate entry ’21’ for key ‘PRIMARY’ I want to UPDATE the primary key field in this case it’s called ‘id’ to another value …
Tag: mariadb
SQL – Generate column from sum of columns from different table
I have two tables: The first one contains numeral values, it looks like this: The id column is the primary key; it has the attribute AUTO_INCREMENT. All columns have the datatype INT. Now my …
Update every 5 minutes a value
I am using a MySql DataBase and I want to know if there are any methods to modify a value of a column every x minutes/hours/days. For example, I want to execute the following query every 5 minutes, UPDATE table SET x=0;. Could I set an event or something like this from the PHPMyAdmin interface? Answer I’m not aware about
How to get a COUNT() value when GROUP BY has no row?
RDMS : MariaDB 10.1.23 MCRE : SQLFiddle: http://sqlfiddle.com/#!9/f32a01/1 Consider the following query : Without the GROUP BY clause, I know that COUNT() will return 0 if no row match the query. I also know that, if my GROUP BY “fails” (If i have no row to group by, in my example, if no row satisfy e.created_at > CURRENT_DATE – INTERVAL
Matching two values of different types in two SQL databases
I am trying to compare records between two different SQL tables/databases in my Node project and have to do some transformation in order to compare the values. In one database (MariaDB) the value is of type INT, and looks like this: 516542 In the other (SQL Server) database the value I need to match to is of type char(21), and
SQL Query with REGEXP to change URL strings dynamically
My DB table named “post” does look as follows So not every message row does contain an url and not every message with a [LINK]-tag does contain a proper url. Also there are enrties which have a longer ID, they should not be changed. Now i have to change every entry which has an ID length between 4 and 5
SQL query joining two different tables. Find online status from user’s last interaction
Problem description: Finding online status of therapist users based on last interaction in Session table. Cannot keep last interaction date on User table but it should be separated on Session table. But how can I join one row for each user with User table information and session data of Session table for user’s last interaction for each record? Description of
how to fetch top 9 and others based on count(entity_id) sorted highest top 9 and then club the other count into ‘others’ category
The following query executes everything: SELECT count(entity_id), cim.institute_id, cfi.name_ FROM ci_certification_students cis INNER JOIN ci_certification_master cim ON cis.certificate_id = cim….
How to tell MariaDB/MySQL that a column is unique due to HAVING clause
With ONLY_FULL_GROUP_BY set (which I don’t want to/can’t change) the following query errors with ERROR 1055 (42000): ‘dbname.test1.person_id’ isn’t in GROUP BY (or equivalent longer message in mariadb). How can I “tell” MySQL that I know the person_id is unambiguous because of the HAVING clause? I don’t want to use ANY_VALUE because that isn’t available in all the dbs where
SQL error syntax, please check the manual that corresponds to your MariaDB server version for the right syntax to use
I try to insert a new value into a table by using preparedStatement but I obtain a syntax error that I can’t solve. Java code : Error Code : I hope that you can help me thank you. Answer I see several potential problems here. First, you are passing the SQL string to executeUpdate(), which is incorrect. It is wrong