Is this the appropriate way to insert information into a database with 2 tables (related with empID fields)
INSERT INTO table1
empID, first, last, dept, district
INSERT INTO table 2
className, classType, classDate
I am using ColdFusion to send the information to the database.
Thanks!Originally posted by helios76
Is this the appropriate way to insert information into a database with 2 tables (related with empID fields)
INSERT INTO table1
empID, first, last, dept, district
INSERT INTO table 2
className, classType, classDate
I am using ColdFusion to send the information to the database.
Thanks!
uhhhh...no
post the ddl for your tables...syntax is
INSERT INTO myTable (col1, col2, ect)
SELECT col1, col2, ect
FROM SomeOtherTable|||OK, full story of what I am trying to do.
Create a form that will go through ColdFusion to the database. This is how CFMX uses the SQL commands:
<cfquery name="AddEmployee" datasource="CompanyInfo">
INSERT INTO Employee
(Emp_ID,FirstName,LastName, Dept_ID,Contract)
VALUES (#Form.Emp_ID#,'#Form.FirstName#','#Form.LastName# ', #Form.Dept_ID#,'#Form.Contract#')
</cfquery>
The #Form.Emp_ID# is how CFMX knows what was entered on the HTML form and then sends it to the database.
What my goal is, is to send data to 2 tables that are linked by Emp_ID in the same database.|||Originally posted by helios76
OK, full story of what I am trying to do.
Create a form that will go through ColdFusion to the database. This is how CFMX uses the SQL commands:
<cfquery name="AddEmployee" datasource="CompanyInfo">
INSERT INTO Employee
(Emp_ID,FirstName,LastName, Dept_ID,Contract)
VALUES (#Form.Emp_ID#,'#Form.FirstName#','#Form.LastName# ', #Form.Dept_ID#,'#Form.Contract#')
</cfquery>
The #Form.Emp_ID# is how CFMX knows what was entered on the HTML form and then sends it to the database.
What my goal is, is to send data to 2 tables that are linked by Emp_ID in the same database.
You could add another insert in batch like this:
<cfquery name="AddEmployee" datasource="CompanyInfo">
INSERT INTO Employee
(Emp_ID,FirstName,LastName, Dept_ID,Contract)
VALUES (#Form.Emp_ID#,'#Form.FirstName#','#Form.LastName# ', #Form.Dept_ID#,'#Form.Contract#')
INSERT INTO Employee2
(Emp_ID,FirstName,LastName, Dept_ID,Contract)
VALUES (#Form.Emp_ID#,'#Form.FirstName#','#Form.LastName# ', #Form.Dept_ID#,'#Form.Contract#')
</cfquery>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment