ElijahLoop Posted February 11, 2021 Share Posted February 11, 2021 Hello everyone. I'm a self learner that is very new to programming. Three tables are given: table `worker` (worker) with data - id (worker id), first_name (name), last_name (last name) table `child` (child) with data - worker_id (worker id), name (child name) table `car` (machine) with data - worker_id (worker id), model (car model) Table structure: CREATE TABLE `worker` ( `id` int(11) NOT NULL, `first_name` varchar(100) NOT NULL, `last_name` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; CREATE TABLE `car` ( `user_id` int(11) NOT NULL, `model` varchar(100) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `child` ( `user_id` int(11) NOT NULL, `name` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; It is necessary to write one SQL query that returns: names and surnames of all employees, a list of their children separated by commas and a car brand. You need to select only those workers who have or had a car (if there was a car and then it was gone, then the model field becomes null). Quote Link to comment Share on other sites More sharing options...
requinix Posted February 11, 2021 Share Posted February 11, 2021 Sounds like a homework assignment. What have you tried so far and what happened when you tried it? Quote Link to comment Share on other sites More sharing options...
ElijahLoop Posted February 11, 2021 Author Share Posted February 11, 2021 I'm just learning. And I'm not familiar with sql. Quote Link to comment Share on other sites More sharing options...
Barand Posted February 11, 2021 Share Posted February 11, 2021 You will need INNER JOIN LEFT JOIN GROUP BY GROUP_CONCAT There's a link to SQL tutorials in my sig that might help. Quote Link to comment Share on other sites More sharing options...
ElijahLoop Posted February 11, 2021 Author Share Posted February 11, 2021 Okay thank you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.