我有 3 个表:
tblNames
:
| id | firstname | lastname |
+------+---------------+--------------+
| 1 | John | Smith |
tblJosbs
(该表同时接受多个复选框值):
| id | jobs |
+------+-----------------------+
| 1 | Nurse |
+------+-----------------------+
| 2 | Call Center Agent |
+------+-----------------------+
| 3 | Police |
tblNamesJobs
(此表用于JOIN
其他 2 个表):
| id | name_id | jobs_id |
+------+-------------+-------------+
| 1 | 1 | 1 |
+------+-------------+-------------+
| 2 | 1 | 2 |
+------+-------------+-------------+
| 3 | 1 | 3 |
一切都很好,但有人可以告诉我当我添加新信息时应该使用的第三个表的 INSERT
语句吗?
最佳答案
例如添加John Smith是调用中心代理的记录
insert into tblNamesJobs (name_id,jobs_id )
values (
select id from tblNames where
firstname='John'
and lastname='Smith' limit 1
,
select id from tblJosbs where jobs='Call Center Agent' limit 1
);
关于php - 连接表中的 INSERT 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14079646/