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

SQLize | PHPize | SQLtest

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

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
create table table1 ( column1 INT, column2 INT, column3 INT); INSERT INTO table1 VALUES ('333', '222', '111'); INSERT INTO table1 VALUES ('111', '222', '333'); INSERT INTO table1 VALUES ('222', '111', '333'); INSERT INTO table1 VALUES ('111', '222', '333'); INSERT INTO table1 VALUES ('222', '222', '222'); with concat_union as ( SELECT CONCAT(column1, column2, column3) as COMB, 'ORIG' as TYPE from table1 where CONCAT(column1, column2, column3) = '111222333' UNION ALL SELECT CONCAT(column1, column3, column2) as COMB, 'GEN' as TYPE from table1 UNION ALL SELECT CONCAT(column2, column1, column3) as COMB, 'GEN' as TYPE from table1 UNION ALL SELECT CONCAT(column2, column3, column1) as COMB, 'GEN' as TYPE from table1 UNION ALL SELECT CONCAT(column3, column1, column2) as COMB, 'GEN' as TYPE from table1 UNION ALL SELECT CONCAT(column3, column2, column1) as COMB, 'GEN' as TYPE from table1 ) select count(COMB) from concat_union where COMB = (select distinct COMB from concat_union where TYPE = 'ORIG');

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

Copy Clear