A
Anonymous
Guest
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:
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).
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:
Code:
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).