1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

With a header-and-detail structure, how do I populate a header from the first detail?

Discussion in 'MySQL' started by James H. H. Lampert, Mar 20, 2019.

  1. #1
    Given a header-and-line-item structure, in MySQL (in this case, a quote header and its details), we have a field at the detail level, "Vendor," and we are adding a new field at the header level, call it "PrimaryVendor."

    Going forward, the application will pull use the value of "PrimaryVendor" as a default for the detail-level "Vendor."

    But for the existing database (thousands of records, an average of around four details per quote), we need to put something in the new field, and the preferred value is the Vendor field for the first (i.e., lowest record ID) detail.

    Obviously, a program could be written to do it, in any number of languages, but can it be done with an SQL query? If so, how?
     
    James H. H. Lampert, Mar 20, 2019 IP