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

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

new
Ethnic Beauty
Adolescence
Middle Eastern Culture
Yoga
Vision Issues
Paper Crafts
Comedy Movies


dailyclick
All times in EST

Full Schedule
g
g ASP Site
Editor Wanted
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!

SQL Updating
RSS
Related Articles
Previous Features
Site Map

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


Content copyright © 2009 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


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

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

jobs
what
job title, keywords
where
city, state or zip
jobs by job search


vote
Growing a Garden
Veggies and Flowers
Veggies Only
Flowers Only
No Garden

g


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


BellaOnline Editor