SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE `tbl_office` ( id int primary key auto_increment, name varchar(64) ); INSERT INTO `tbl_office` (`name`) VALUES ('Records'), ('Logistics'), ('HR'); CREATE TABLE `tbl_rating` ( id int primary key auto_increment, name varchar(64) ); INSERT INTO `tbl_rating` (`name`) VALUES ('Satisfied'), ('Neutral'); CREATE TABLE `tbl_result` ( id int primary key auto_increment, office_id int, rating_id int, comment text ); INSERT INTO `tbl_result` (`office_id`, `rating_id`) VALUES (1, 1), (2, 1), (3, 2); SELECT `res`.`id`, `o`.`name` AS `office`, `r`.`name` AS `rating`, `comment` FROM `tbl_result` `res` JOIN `tbl_office` `o` ON `o`.`id` = `res`.`office_id` JOIN `tbl_rating` `r` ON `r`.`id` = `res`.`rating_id`
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear