Skip to content
Advertisement

Tag: mysql

Change MySQL query execution order

I want to put a entry in the database with id of 2. In order to do that I’m moving all records having more than 2 to id + 1. Because id is a primary key. This query is failing saying : #1062 – Duplicate entry ‘3’ for key ‘PRIMARY’. I know this is happening because query execution starts from

What is the functioning of “->” operator in MYSQL joins?

I’m using Sequelize, and trying to learn from the queries it constructs. I have some complicated one-to-many relationship between few models, so i come across this query: The query itself is not important, but i would like to understand the meaning of the “->” operator, like in: ScrumLists->ScrumCards.content AS ScrumLists.ScrumCards.content Answer In this context, the -> has no special meaning.

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

What’s best practice for normalisation of DB where a domain table has an “Other” option for free text?

I’m currently in the process of normalising a database for my company and one pattern I’m seeing a lot in this database is using a domain lookup table for a value but also allowing “Other” and storing the results in a separate column. My question is just whether there is perhaps a cleaner way of representing this? For context I’m

Select all orders except the max order for each distinct customer

Sorry for the poor formatting but as part of a larger problem, I have created a query that produces this table: How would I extract the rows that don’t have the highest id2 for each id1. What I want: I can only seem to figure out how to get rid of the max id2 overall but not for each distinct

Advertisement