SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    delaware
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    General SQL how to question

    Hi this is general how to question and does not really pertain to any particular language.

    To keep it simple let's say you have a page with a list of customer's names. You click on the user to edit the user. A new page loads with text fields containing all the user's information such as first, last, email, address, etc.

    Let's say I update the email address, when you click update what is the normal procedure SQL wise? Since you don't know what fields were changed do you run the UPDATE query on all fields even though not all fields may have been updated? Maybe you have an array with all fields and their values and then compare what has changed and then only update that one value? Sorry for the ignorance but I have never understood how this scenario would be handled.

    Thanks.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    It depends on whether you have a separate update form for each field or just the one form to update multiple fields at the same time. If you use the more usual single form with multiple fields then all of those fields HAVE been updated when the form is submitted even if their new value is the same as the old value that was there before.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by da manual
    If you set a column to the value it currently has, MySQL notices this and does not update it.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •