Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
How to run query to keep maximum 3 rows with the same name
drop table if exists ss_remote_inventories; CREATE TABLE ss_remote_inventories (`id` int, `item_name` varchar(5), `price_good` int) ; INSERT INTO ss_remote_inventories (`id`, `item_name`, `price_good`) VALUES (1, 'Row 1', 1), (2, 'Row 1', 1), (3, 'Row 1', 0), (4, 'Row 1', 0), (5, 'Row 1', 1), (6, 'Row 1', 1), (7, 'Row 1', 1), (8, 'Row 1', 1), (9, 'Row 2', 0), (10, 'Row 2', 1) ; update ss_remote_inventories t set t.price_good = 0 where id in ( select id from( select a.* from ss_remote_inventories a where a.price_good = 1 and ( select count(*) from ss_remote_inventories b where a.item_name = b.item_name and b.price_good = 1 and a.id > b.id ) > 2 ) t1 ); select * from ss_remote_inventories
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Test for MySQL "serializable" transaction, part 1
BASE DE DATOS
mysql - order by,limit,offset
chandu
find tax rates for current time period
gandu
practice
Amp
mysql datetime to date selected using in list
admin@pkms99.info
Please log in to post a comment.