这里我试图插入来自两个不同表格的patient_id和nurse_id。
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;))
这是正确的做法吗?
答案 0 :(得分:0)
查询将如下:
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);
答案 1 :(得分:-1)
尝试这样的事情:
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 )
答案 2 :(得分:-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