SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create table types ( id int auto_increment primary key, title varchar(255) ); insert into types (title) values ('Одежда'); create table categories ( id int auto_increment primary key, type_id int, title varchar(255), foreign key (type_id) references types(id) ); insert into categories (type_id, title) values (1, 'Брюки'), (1, 'Рубашки'); create table goods ( id int auto_increment primary key, category_id int, title varchar(255), foreign key goods_category (category_id) references categories(id) ); insert into goods (category_id, title) values (1, 'Брюки мужские'), (2, 'Рубашка поло спорт'); select goods.id, types.title as type, categories.title as category, goods.title from goods join categories on goods.category_id = categories.id join types on categories.type_id = types.id ;
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear