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 CREATE TABLE station_units ( id INTEGER PRIMARY KEY, unit_id text NOT NULL ); -- insert INSERT INTO station_units (id, unit_id) VALUES (0001, 'unit_0001'); INSERT INTO station_units (id, unit_id) VALUES (0002, 'unit_0002'); INSERT INTO station_units (id, unit_id) VALUES (0003, 'unit_0003'); INSERT INTO station_units (id, unit_id) VALUES (0004, 'unit_0004'); -- create CREATE TABLE analytic_mode_units ( unit_id text PRIMARY KEY, m_uid text NOT NULL, m_name text NOT NULL ); -- insert INSERT INTO analytic_mode_units (unit_id,m_uid,m_name) VALUES ('unit_0001','mode_0001','m_name_1'); INSERT INTO analytic_mode_units (unit_id,m_uid,m_name) VALUES ('unit_0002','mode_0002','m_name_2'); INSERT INTO analytic_mode_units (unit_id,m_uid,m_name) VALUES ('unit_0003','mode_0003','m_name_3'); INSERT INTO analytic_mode_units (unit_id,m_uid,m_name) VALUES ('unit_0004','mode_0004','m_name_4'); -- create CREATE TABLE analytic_module_cond ( m_uid text PRIMARY KEY, other text NOT NULL ); -- insert INSERT INTO analytic_module_cond (m_uid, other) VALUES ('mode_0001', 'other_text_1'); INSERT INTO analytic_module_cond (m_uid, other) VALUES ('mode_0002', 'other_text_2'); INSERT INTO analytic_module_cond (m_uid, other) VALUES ('mode_0003', 'other_text_3'); INSERT INTO analytic_module_cond (m_uid, other) VALUES ('mode_0004', 'other_text_4'); SELECT * FROM analytic_module_cond INNER JOIN (SELECT * FROM analytic_mode_units INNER JOIN (SELECT * FROM station_units WHERE (id=0001)) ON a_mode.unit_id=station_units.unit_id as a_mode) ON analytic_module_cond.m_uid=a_mode.m_uid

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

Copy Clear