|
 |
asp_databases thread: RE: adding to joined tables
Message #1 by "Drew, Ron" <RDrew@B...> on Tue, 23 Apr 2002 17:59:15 -0400
|
|
In the form you have text boxes for name etc and drop downs for dept and
location selections correct?
Ok so when the user picks the selection you need to get the value of the
selection to match the ID and put it in a hidden field that can be
passed to the asp to update/add
<SCRIPT LANGUAGE=3D"JavaScript">
<!-- Hide from old browsers --
function selectloc(){
var opt =3D document.formname.locs.selectedIndex;
var loc =3D eval("document.formname.locs.options["+opt+"].value");
if (loc !=3D "No Change") {
document.formname.loc.value =3D loc;
}
}
// -- end hiding -->
</SCRIPT>
<INPUT type=3D"hidden" NAME=3D"loc" SIZE=3D1 value=3D"">
<SELECT size=3D"1" name=3D"locs" onChange=3D"selectloc()">
<OPTION VALUE=3D" " SELECTED>No Change
<OPTION VALUE=3D"a">a
<OPTION VALUE=3D"b">b
<OPTION VALUE=3D"c">c</OPTION>
</SELECT>
-----Original Message-----
From: Vic [mailto:vweston@m...]
Sent: Tuesday, April 23, 2002 6:48 AM
To: ASP Databases
Subject: [asp_databases] adding to joined tables
I have three tables.
Table1 contains the following fields: tel_id, fname, sname, extension,
dept_id, loc_id.
Table2 contains: department, dept_id.
Table3 contains: location, loc_id.
My select statement is like this:
SELECT p.fname, p.sname, p.extension, d.department, o.location FROM
personnel_list LEFT OUTER JOIN officelocations ON p.loc_id =3D o.loc_id
LEFT OUTER JOIN departments ON p.dept_id =3D d.dept_id
I would like to add/update these details via a web page. For the add
page,
I have created a form with blank text boxes for the fname, sname,
extension fields and list boxes that loop through the departments and
locations from their individual tables.
My problem is how to write an update statement that sets the p.dept_id
=3D
d.dept_id of the department chosen and the same with the location
details.
I can only find select statement examples when working with joined
tables.
Any help at all would be much appreciated. Thanks.
Message #2 by "Kim Iwan Hansen" <kimiwan@k...> on Tue, 23 Apr 2002 23:45:38 +0200
|
|
You don't use joins for insert/update/delete statements - To do any of
those, you have to do it once for each table involved.
For example:
conn.execute("INSERT INTO tbl (UserName, userid) VALUES ('vweston',
123456)")
conn.execute("INSERT INTO profiles (userid, LastName, Email) VALUES
(123456, 'Weston', 'vweston@m...')")
-Kim
-----Original Message-----
From: Vic [mailto:vweston@m...]
Sent: 23. april 2002 10:48
To: ASP Databases
Subject: [asp_databases] adding to joined tables
I have three tables.
Table1 contains the following fields: tel_id, fname, sname, extension,
dept_id, loc_id.
Table2 contains: department, dept_id.
Table3 contains: location, loc_id.
My select statement is like this:
SELECT p.fname, p.sname, p.extension, d.department, o.location
FROM personnel_list LEFT OUTER JOIN officelocations ON p.loc_id = o.loc_id
LEFT OUTER JOIN departments ON p.dept_id = d.dept_id
I would like to add/update these details via a web page. For the add page,
I have created a form with blank text boxes for the fname, sname,
extension fields and list boxes that loop through the departments and
locations from their individual tables.
My problem is how to write an update statement that sets the p.dept_id
d.dept_id of the department chosen and the same with the location details.
I can only find select statement examples when working with joined tables.
Any help at all would be much appreciated. Thanks.
Message #3 by "Vic" <vweston@m...> on Tue, 23 Apr 2002 10:47:50
|
|
I have three tables.
Table1 contains the following fields: tel_id, fname, sname, extension,
dept_id, loc_id.
Table2 contains: department, dept_id.
Table3 contains: location, loc_id.
My select statement is like this:
SELECT p.fname, p.sname, p.extension, d.department, o.location
FROM personnel_list LEFT OUTER JOIN officelocations ON p.loc_id = o.loc_id
LEFT OUTER JOIN departments ON p.dept_id = d.dept_id
I would like to add/update these details via a web page. For the add page,
I have created a form with blank text boxes for the fname, sname,
extension fields and list boxes that loop through the departments and
locations from their individual tables.
My problem is how to write an update statement that sets the p.dept_id =
d.dept_id of the department chosen and the same with the location details.
I can only find select statement examples when working with joined tables.
Any help at all would be much appreciated. Thanks.
|
|
 |