logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Painting
Heart Disease
Horror Literature
Dating
Hiking & Backpacking
SF/Fantasy Books
Healthy Foods


dailyclick
All times in EST

Autism Spectrum Disorders: 4:00 PM

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Advanced SQL Update Command: Using Two Tables

Guest Author - Lisa Shea

There are times that you need to update one SQL database table, and want to use values from another table to do the update with. Here is how you would do that in ASP.

First, the scenario to make this easier to understand. Let's say you are moving servers for some reason. You had a "traffic" table on the old server that had the fields page_id and hit_count. You also have a "traffic" table on the new server, with those same fields. Now that you are done moving, you want to combine those two traffic figures together so you have one table with your total traffic.

First, you would move the data from the old server into the new server, into a table called "traffic_old". So the two tables are side by side on the new server. The SQL syntax to add those old traffic numbers into the new one would be:

update traffic
set hit_count = traffic.hit_count + to.hit_count
from traffic_old to
where traffic.page_id = to.page_id;

That command will update the traffic table so that each page ID's value is now equal to its original value plus the matching value from traffic_old.

For the full ASP shell, read the Intro to Updating in ASP

If you're using character/string values, be sure to read about Handling Apostrophes in Input Fields to make sure your input fields are ready for use in SQL.

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.
This site needs an editor - click to learn more!

Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Twitter Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Facebook Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to MySpace Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Del.icio.us Digg Advanced+SQL+Update+Command%3A+Using+Two+Tables Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Yahoo My Web Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Google Bookmarks Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Stumbleupon Add Advanced+SQL+Update+Command%3A+Using+Two+Tables to Reddit




SQL Updating
RSS
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2013 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2013 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor