D
D
Dmitry2017-04-15 23:16:26
MySQL
Dmitry, 2017-04-15 23:16:26

Error creating Foreign Key?

I want to create for the table "Hotel rooms" ( rooms) a foreign key to the table "Room size" ( roomsize).
I create through the phpmyadmin admin panel, the generated SQL query looks like this:

ALTER TABLE `rooms` 
ADD CONSTRAINT `room_size` 
FOREIGN KEY (`id_room_size`) 
REFERENCES `hotel`.`roomsize`(`id_room_size`) 
ON DELETE RESTRICT 
ON UPDATE RESTRICT;

As a result, it gives the following error:
bb118a0163474f65a0df9238563b959f.png
How to fix this error?
UPDATE:
I also tried to make a connection like this, but again an error492aab56e46f4fe089720e15e9385d22.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2017-04-16
@letehaha

To start:

select * from rooms where rooms.id_room_size not in (
select id_room_size from hotel.roomsize
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question