Skip to content
Advertisement

Tag: mysql

mysql how to show order number in result

so here is the query select * from test order by pow(c1 – 8, 2) + pow(c2 – 5, 2) limit 3 is there any way to show order section -> “pow(c1 – 8, 2) + pow(c2 – 5, 2)” for each record in result ?

Conditional UPDATE MariaDB (MySQL)

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 …

Query returns multiple id’s

I have a query that finds the most frequent numbers in multiple columns (named S1, S2, S3, S4, S5 and S6. The query seems to be working pretty good, but it doesn’t count the total number per id in the …

mysql update with if and max

I have lost hours on this and nothing works for me. I have filed strp_aa that is default NULL. The filed strp_aa should update only if its null with MAX strp_aa + 1, and if its not null if it already has a number it should stay the same. short version of code is Also tired I tried multiple things

Sort a table but keep groups of rows together

How do I sort a table by it’s minimum value per group but at the same time keep a group of rows together. Below a simple example of what i am trying to accomplish. The table is sorted by the lowest group value, but the group remains together. I am pretty sure this question has been asked already but i

Group by not getting the expected results in mysql

I have the next query: That is working perfectly and returning 9 rows: I want to group the results by boat type and get the number of boats per type. However, when I do: I´m getting: but according to the first query, I´m expecting What am I missing? Answer I suspect that you want: That is: move the DISTINCT within

Advertisement