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 Post ( id INT, published BOOL CHECK(published IN(TRUE,FALSE)) ); INSERT INTO Post (id, published) VALUES (1, true), (2, true), (3, false), (4, true), (5, true), (6, false), (7, true); CREATE TABLE Pages ( id INT, published BOOL CHECK(published IN(TRUE,FALSE)) ); INSERT INTO Pages (id, published) VALUES (1, false), (2, true), (3, true); CREATE TABLE Products ( id INT, published BOOL CHECK(published IN(TRUE,FALSE)) ); SELECT * FROM Post; SELECT * FROM Pages; SELECT * FROM Products;

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

Copy Clear
Copy Format Clear
<?php var_export( $db->table('Post') ->whereRaw('published = true') ->selectRaw('COUNT(*) posts') ->selectRaw('(' . $db->table('Pages')->whereRaw('published = true')->selectRaw('COUNT(*)')->toSql() . ') pages') ->selectRaw('(' . $db->table('Products')->whereRaw('published = true')->selectRaw('COUNT(*)')->toSql() . ') products') //->toSQL() ->get() ->first() );
Copy Clear