SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
CREATE TABLE inventory_player ( id int(11) NOT NULL AUTO_INCREMENT, user_id int(11) NOT NULL, item_id int(11) NOT NULL, slot_id int(11) NOT NULL, deleted_at_time datetime DEFAULT NULL, PRIMARY KEY (id) ); INSERT INTO inventory_player VALUES (1, 4, 0, 0, NULL), (2, 4, 0, 1, NULL), (3, 4, 0, 2, NULL), (4, 4, 0, 3, NULL), (5, 4, 1, 4, NULL), (6, 4, 1, 4, NULL), (7, 4, 1, 4, NULL), (8, 4, 1, 4, NULL), (9, 4, 1, 4, NULL); SELECT * FROM inventory_player order by id; SET @ids := null; WITH old as ( SELECT *, DENSE_RANK() OVER (order by item_id DESC) - 1 dr, ROW_NUMBER() OVER (PARTITION BY item_id order by id) rn FROM inventory_player ), jn as ( SELECT o1.id, o1.user_id, o1.item_id, o2.slot_id FROM old o1 INNER JOIN old o2 ON o2.dr = o1.item_id and o1.rn = o2.rn ) UPDATE inventory_player ip INNER JOIN jn ON jn.id = ip.id SET ip.slot_id = jn.slot_id WHERE (SELECT @ids := CONCAT_WS(',', ip.id, @ids)); DELETE FROM inventory_player where id in (@ids); SELECT * FROM inventory_player order by id;
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear