Adding New Records To Multiple Tables

Results 1 to 2 of 2

Thread: Adding New Records To Multiple Tables

  1. #1
    H. Wong Guest

    Default Adding New Records To Multiple Tables

    I&#039m relatively new to ASP and I have read the articles on this site pertaining to inserting form responses to databases. I may have missed the appropriate article, but I would like to know how to insert form responses to tables that have relationships between them instead of just one table. <BR><BR>Thanks.

  2. #2
    Zola Guest

    Default RE: Adding New Records To Multiple Tables

    It depends on what you mean. If you have the same fields in separate tables, you may want to read Todd Bailey&#039s very fine article on Normalizing databases. Ideally, you would have all unique fields.<BR><BR>You could also set a lookup in the field--have one field in one table refer to a field in another.<BR><BR>If it is a matter of placing the form responses into different tables, it is a matter of opening all pertinent tables in SQL:<BR><BR>SQL = SELECT * FROM Table1, Table2, Table3<BR><BR>If the tables are linked, you will need to create an inner join so that you can select distinct recordsets, such as if one table holds name and address, another favorite web sites, and still another favorite foods, and you want to be able to call up the user&#039s favorite sites and foods when you bring up their name. <BR><BR>There are articles here on setting up an inner join--a word of caution, also. Even if not all users will add data to a particular table, you MUST have an entry in each joined table so that the whole set is created at once. I do this by means of passing hidden info along with the rest of the form. What I do is create a null field in each table beyond the primary one.<BR><BR>So, to use the simple example, I have a field in the favorite web sites table called "SNull", and one in the foods table called "FNull". My form then has the hidden input:<BR><BR>&#060;input type="hidden" name="SNull" value="X"&#062;&#060;input type="hidden" name="FNull" value="X"&#062;. <BR>That way, no matter what portion of the form the user does or doesn&#039t fill out, the entire record is created at that time and can be updated easily. You could also accomplish the same thing by having SOMETHING in the form field in advance, even if it is just a couple of spaces.<BR><BR>If you would like to see examples, please mail me privately at

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts