В этой статье я хочу показать новще решение распостраненной задачи. Найти в таблице записи с максимальным значением в одной из колонок.
Для примера мы будем искать сотрудников с максимальной зарплатой.
Since MySQL 8 you can use pretty short query to select all data from table.
Just use TABLE a; instead SELECT * FROM a; and get same result
On Sakila Database we have table category represented categories of movies in DB and table film_category where each film linked it it's category (one film can be present in more then one category).
The simplest way to fix order in primary key column is drop it and create again. Assume we have the test where id is column values not in order
Assume we have 3 tables items, categories and item_categories where stored records about items, categories and relations between them
Assume we have table with integer column. How we can find is all values of this column are sequence without gaps or duplicates.
One more case using CTE (common table expressions). Assume we have table of financial transactions like posted below, where Id is transaction identifier integer auto increment without gaps, Type is D for deposits and W for withdrawals
MySQL solution (using rlike):
Assume we have table stored values within json array. For example:
Let we have some one table contains duplicates values: