Question: I have the following code. The output i keep getting has my pid values in the wrong order. Any help is appreciated. my code: INSERT
I have the following code. The output i keep getting has my pid values in the wrong order. Any help is appreciated.
my code:
INSERT INTO works_on (pid,eid,start_date) VALUES ( (SELECT cid FROM project WHERE name="Chan'g"), (SELECT id FROM employee WHERE first_name='Ananya' AND last_name='Jaiswal'), '2012-01-01' );
INSERT INTO works_on (pid,eid,start_date) VALUES ( (SELECT cid FROM project WHERE name='The Robinson Project'), (SELECT id FROM employee WHERE first_name='Michael' AND last_name='Fern'), '2013-08-08' );
INSERT INTO works_on (pid,eid,start_date) VALUES ( (SELECT cid FROM project WHERE name='Diamond'), (SELECT id FROM employee WHERE first_name='Abdul' AND last_name='Rehman'), '2014-09-11' );
Additional code:
INSERT INTO project (cid,name,notes) VALUES ( (SELECT id FROM client WHERE first_name='Sara' AND last_name='Smith'), 'Diamond', 'Should be done by Jan 2019' );
INSERT INTO project (cid,name,notes) VALUES ( (SELECT id FROM client WHERE first_name='Bo' AND last_name='Chang'), "Chan'g", 'Ongoing maintenance' );
INSERT INTO project (cid,name,notes) VALUES ( (SELECT id FROM client WHERE first_name='Miguel' AND last_name='Cabrera'), 'The Robinson Project', 'NULL' );
my output:
YOUR CODE'S OUTPUT
id cid name notes 1 1 Diamond Should be done by Jan 2019 2 3 Chan'g Ongoing maintenance 3 2 The Robinson Project NULL id first_name last_name dob 1 Sara Smith 1970-01-02 2 Miguel Cabrera 1988-02-02 3 Bo Chang 1985-03-02 id first_name last_name dob date_joined 1 Ananya Jaiswal 1975-01-02 2009-01-01 2 Michael Fern 1980-10-18 2013-06-05 3 Abdul Rehman 1984-03-21 2013-11-10 eid pid start_date 1 3 2012-01-01 2 2 2013-08-08 3 1 2014-09-11
Expected output:
THE CORRECT OUTPUT OF THE TEST CASE
id cid name notes 1 1 Diamond Should be done by Jan 2019 2 3 Chan'g Ongoing maintenance 3 2 The Robinson Project NULL id first_name last_name dob 1 Sara Smith 1970-01-02 2 Miguel Cabrera 1988-02-02 3 Bo Chang 1985-03-02 id first_name last_name dob date_joined 1 Ananya Jaiswal 1975-01-02 2009-01-01 2 Michael Fern 1980-10-18 2013-06-05 3 Abdul Rehman 1984-03-21 2013-11-10 eid pid start_date 1 2 2012-01-01 2 3 2013-08-08 3 1 2014-09-11
the pid (2, 3) output is out of order, any help is appreciated
Insert the following into the works_on table. Again, your queries here should not have hard-coded integers for foreign keys.
| employee | project | start_date |
| Ananya Jaiswal | Chan'g | 1/1/2012 |
| Michael Fern | The Robinson Project | 8/8/2013 |
| Abdul Rehman
| Diamond
| 9/11/2014
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
