Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear
CREATE TABLE yourTable ( id INTEGER PRIMARY KEY AUTO_INCREMENT, column1 INTEGER, column2 INTEGER ); INSERT INTO yourTable (column1, column2) VALUES (1, 4), (2, 5), (3, 6);

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php var_export( $db::table('yourTable') ->select('column1 as res') ->unionAll( $db::table('yourTable') ->select('column2 as res') ) ->get() ->toArray() );
Copy Clear