Updating multiple records in a linked table simultaneously

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Updating multiple records in a linked table simultaneously

    I am working on an e-commerce application and I need help with
    updating the product details for a single product with multiple
    formats.

    --DB STRUCTURE---

    Products table:

    tbl_Products

    fld_prodID (PK, autonum)
    fld_prodTitle
    fld_prodDesc

    Linking Table:

    tbl_Prod_details

    fld_prodID (FK)
    fld_formatID (FK)

    Product Formats table:

    tbl_ProdFormat

    fld_formatID (PK, autonum)
    fld_formatTitle

    If I wanted to update this product and select multiple formats, would
    I have to build two update queries or could I do it with one? What
    would the SQL look like?

    Thanks for your help and suggestions!
    -Aaron
    Aaron Roberson Guest

  2. Similar Questions and Discussions

    1. Updating Multiple records fields in a database atonce
      Is it correct that there is no user interaction on these forms? I didn't see a submit button. Or does someone click on a submit button to get to...
    2. Updating Multiple Database Rows Simultaneously
      Hi, I'm having some trouble with something that should be relatively easy. I want to update multiple rows in one of my database tables...
    3. updating multiple records on one page
      I'm a moderate newcomer to ASP... I have a SQL Server database. I am displaying multiple records on a page. I have a field in the database called...
    4. updating multiple records via online form
      Hello, I have a database generated form that I would like users to be able to update by selecting a checkbox. Say the page displayed has six...
    5. Updating Multiple Records
      I have a table in a database that contains all my photos. The fields are like Name, SRC, GalleryName, DateAdded, SpecialStyle. The only one you may...
  3. #2

    Default Re: Updating multiple records in a linked tablesimultaneously

    If the only thing you are doing is giving a product more formats, the answer
    might be that you don't run any update queries. You run insert queries into
    your tbl_Prod_details table.

    If you are changing a format, you do something like

    update tbl_Prod_details
    set fld_formatID = theNewNumber
    where fld_prodID = somenumber
    and fld_formatID = theOldNumber


    Dan Bracuk Guest

  4. #3

    Default Re: Updating multiple records in a linked table simultaneously

    Dan Bracuk wrote:
    > If the only thing you are doing is giving a product more formats, the answer
    > might be that you don't run any update queries. You run insert queries into
    > your tbl_Prod_details table.
    >
    > If you are changing a format, you do something like
    >
    > update tbl_Prod_details
    > set fld_formatID = theNewNumber
    > where fld_prodID = somenumber
    > and fld_formatID = theOldNumber
    >
    >
    In my case, I am updating/inserting multiple formats at once. Therefore,
    the value for "theOldNumber" in the WHERE clause would be more than 1
    number.

    Perhaps I could do something like the following:

    <cfquery name="qFormats" dsn="#application.dsn#">
    SELECT fld_format_ID
    FROM tblprodFormats
    WHERE fld_format_ID = #newID#
    </cfquery>

    <cfif qFormats.recordcount > 0>
    <cfquery name="updateFormats" dsn="#application.dsn#>
    update tbl_Prod_details
    set fld_formatID = #fID#
    where fld_prodID = #pID#
    and fld_formatID = #newID#
    </cfquery>
    <cfelse>
    insertquery
    </cfif>

    However, this would not solve my problem of inserting or updating more
    than one record in the formats table simultaneously.

    Any more help would be greatly appreciated at this point!

    -Aaron
    Aaron Roberson Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139