I have a table "people" with ("ID","PassportNo")
+----------+----------+
| booking | passport |
+----------+----------+
| 1 | 873246 |
| 1 | 535654 |
| 2 | 123232 |
+----------+----------+
CREATE TABLE people(
id INTEGER,
passportno INTEGER,
PRIMARY KEY (id, passportno),
);
And I have a table passenger with ("ticketno","booking","passportno")
+-----------+---------+------------+
| thicketno | booking | passportno |
+-----------+---------+------------+
| 134133434 | 1 | NULL |
| 324214234 | 1 | NULL |
+-----------+---------+------------+
CREATE TABLE passenger(
ticketno INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
booking INTEGER,
passportno INTEGER,
How can I add all "passportno" from "people" table to "passenger" table based on the booking?
I believe it should be something like:
UPDATE passenger SET passportno = (SELECT passpotno FROM people where people.booking=passenger.booking
but I get an error "you are using safe update mode and you tried to update a table without a WHERE that uses a KEY column"
UPDATE:
it works when I add SET SQL_SAFE_UPDATES = 0
; ńow the problem is that I get 'subquery returns more than one row' and when I use a join I get the same passport number for anyone with the same booking id, I'd like to have all the different passport numbers.