here i am trying to insert patient_id and nurse_id which are from two different tables.
insert into nurse_take_care(patient_id,nurse_id) values (patient_id(select MAX(p_id) from patient;), nurse_id(Select n_id from nurse order by Rand() limit 1;))
is this the right way to do??
The query would be like:
insert into nurse_take_care(patient_id,nurse_id) values
(select MAX(p_id) from patient limit 1, Select n_id from nurse order by Rand() limit 1);
Try something like this:
INSERT INTO nurse_take_care (patient_id, nurse_id)
SELECT ( SELECT MAX(p_id) FROM patient ),
( SELECT n_id FROM nurse ORDER BY RAND() LIMIT 1 )
请尝试这个
insert into nurse_take_care(patient_id,nurse_id) SELECT (select MAX(p_id) from patient) as p_id, (select n_id from nurse order by Rand() limit 1) as n_id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.