发出─我是新来的你们:)插入查询与外键
我建立一个java的申请,并卡在之情况与foregign钥匙插入的一个SQL.Need帮助。假设我有2个表Employee_Type和员工
Table **Employee_Type**
idType,
position
Table **Employee**----
empId,
EmpName,
emp_type
FK (emp_type) reference Employee_type(idType)
Now values in **Employee_Type**
1,
Manager
I am inserting manually into Employee Table
insert into **employee** (empId,name,**emp_type**) values (10,'prashant',1)
Here in above insert i am inserting manually **emp_type** which is **FK** . My question, is there any way to insert FK value automatically using select like below example
insert into **employee** (empId,name,emp_type) values (10,'prashant',**(select idType from Employee_type,employee where employee.emp_type=employee_type.idtype))**
Please suggest.
你的错误是什么? – smk