Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 3rd, 2005, 11:47 AM
Authorized User
 
Join Date: Dec 2004
Location: Multan, Punjab, Pakistan.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shankhan Send a message via Yahoo to shankhan
Default scenario for insert query

hi,
i've two tables tab1 and tab2 both tables have four columns. reg_no, page_no, comments. reg_no and page_no having composite key. now i want to write query which insert the records in tab2 by selecting from tab1 and only insert those records which r not in tab2. like in tab1 there two records reg_no=1 and page_no=1, reg_no=1 and page_no=2 while tab2 there are also two records reg_no=1 and page_no=1, reg_no=2 page_no=1 now i want that i write an insert query which check duplicate records and only insert reg_no=1 and page_no=2 otherwise it shows primary key voilation. can any1 help me about this query.

thanx

Reply With Quote
  #2 (permalink)  
Old April 3rd, 2005, 09:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Use "INSERT INTO" statement wtih "SELECT" in it that contains WHERE clause to filter out only the rows that are not in tab2.

Usage: INSERT INTO DEST_TABLE SELECT * FROM tableA, tableB WHERE criteria_part.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use xsl in this scenario travisb777 XSLT 4 September 18th, 2008 04:28 PM
Multi language scenario edgarw BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 May 7th, 2007 08:08 AM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Scenario tonygreaves BOOK: Professional DotNetNuke ASP.NET Portals ISBN: 0-7645-9563-6 1 September 4th, 2005 01:32 AM



All times are GMT -4. The time now is 11:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.