SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist BJ Duncan's Avatar
    Join Date
    Jun 2007
    Location
    Bowen Mountain, NSW
    Posts
    490
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Inserting onto 2 tables but requiring data from 1

    G'day to all,

    I am trying to make a query that grabs data from a form, part of the form has personal details and the other part of the form has business details.

    I have 2 tables in a database :
    Table 1 = clientDetails
    Table 2 = companyDetails

    Within the table of clientDetails there is a field called companyDetailsId, this field is a foreign key field to link companyDetails table with a field within that called companyId.

    My question is, can I have just one query that can insert the data of the companyTable first, then grab that companyId and have it inserted into clientDetails along with all the other personal data.

    Help please - I'm very confused.
    Regards,
    BJ Duncan

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    no

    inserts can be done only one table at a time
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Jun 2008
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    An option to do that itīs make the inserts in order but managed in the code of the application.


Bookmarks

Posting Permissions

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