Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
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);
<?php
var_export(
$db::table('yourTable')
->select('column1 as res')
->unionAll(
$db::table('yourTable')
->select('column2 as res')
)
->get()
->toArray()
);