If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Update statement long and complex

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-03-04, 12:20
enchant enchant is offline
Registered User
 
Join Date: Aug 2004
Posts: 1
Update statement long and complex

Be gentle with me. I'm far from an expert.

I have a perl-based application that uses a table with about 50 fields. When I have a user input their information, the insert statement is fairly simple:
insert into customers values ($name, $address, $city ...

If I want them to update their information, I give them a similar input screen with the current information filled in from the database. They alter what needs to be changed, and the target perl script must enter a statement something like this:

update customers set name=$name, address=$address, city=$city ...

This can get very long. Is there a more streamlined way to do this update, more along the lines of the insert command: values($name, $address, $city ...)

Thanks in advance for any help.
Reply With Quote
  #2 (permalink)  
Old 08-03-04, 13:07
yellowmarker yellowmarker is offline
Registered User
 
Join Date: Jul 2004
Location: Dundee, Scotland
Posts: 107
like...
INSERT INTO customers (`name`,`address`) VALUES ('$name', '$address') ;

... so if you split the update page into multiple pages, the update command on each page would only need to update the fields that could change on any given page.

or, a more complex approach would be, when presenting the update form, hold each field from the database twice in the form. One field is editable, the other would be hidden. Then when processing the update stuff, compare each editable field with it's original and dynamically build the update SQL command so that only the database fields that have changed are updated.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On