Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2005, 11:47 AM
Authorized User
 
Join Date: Dec 2004
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

 
Old April 3rd, 2005, 09:50 PM
Friend of Wrox
 
Join Date: Jun 2003
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





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. [email protected] 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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.