473,503 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specifying Constraints For New Table In SELECT...INTO...

9 New Member
Hello All!

Sorry if this is basic, but I'm having trouble finding a way to specify unique fields (like you would ADD CONSTRAINT in an ALTER TABLE statement) for a new table I'm creating with a SELECT / INTO query.

The table is a list containing, among other fields, names of children (fname and lname), their birthdays and ship addresses. I'd like to pull all the fields from the master table into a new table, retaining only one of any possible duplicate entries (children) in the process in the fname, lname and ShipAddress fields.

Put simply, I'm asking if in a statement like:

SELECT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master

Can constraints be added/specified for tblNewTable?

Any help is greatly appreciated!
Aug 3 '07 #1
1 2884
ADezii
8,834 Recognized Expert Expert
Hello All!

Sorry if this is basic, but I'm having trouble finding a way to specify unique fields (like you would ADD CONSTRAINT in an ALTER TABLE statement) for a new table I'm creating with a SELECT / INTO query.

The table is a list containing, among other fields, names of children (fname and lname), their birthdays and ship addresses. I'd like to pull all the fields from the master table into a new table, retaining only one of any possible duplicate entries (children) in the process in the fname, lname and ShipAddress fields.

Put simply, I'm asking if in a statement like:

SELECT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master

Can constraints be added/specified for tblNewTable?

Any help is greatly appreciated!
You can use the UniqueValues property when you want to omit records that contain duplicate data in the fields displayed in Datasheet view. For example, if a query's output includes more than one field, the combination of values from all fields must be unique for a given record to be included in the results. The DISTINCT Predicate corresponds with the Unique Values Property as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT master.fname, master.lname, master.shipaddr1 INTO NewTable FROM master
Aug 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
4508
by: Agoston Bejo | last post by:
Hi, I'm having trouble with implementing some constraints on the database level. An example: --Table A(AID, BID ref. B.BID, ATXT) --Table B(BID, CID ref. C.CID) --Table C(CID) upon insertion...
1
3002
by: Saqib Ali | last post by:
I have created 2 tables in my MySQL database. A_TAB and B_TAB. They have auto-incrementing integer primary keys respectively named A_ID & B_ID. When I created B_TAB, I declared a field named A_ID...
3
9045
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
4
3479
by: Jon | last post by:
Hi all! I want to create a constraint that uses data from other tables, specifically i want to make sure that a varchar has exactly the length specified in an integer-column in a table that I...
10
6944
by: serge | last post by:
I am doing a little research on Google about this topic and I ran into this thread: ...
0
1613
by: Frnak McKenney | last post by:
One part of a customer project I'm working on involves what seem like fairly straightforward updates to a set of related tables. While I've developed software for a number of years (it only seems...
8
3511
by: wespvp | last post by:
I am using PostgreSQL 7.4.1 on RedHat 7.2. The query I am executing is something like (I replaced all the return values with 'count'): db=> explain select count(*) from messages m join (select...
9
3389
by: Edmund Dengler | last post by:
Greetings! Just trying some tests out, and wanted to know about some optimizations. If I do a CHECK constraint on a table, is this used to optimize a SELECT or does Postgresql rely mostly on...
6
2032
by: Christian Rank | last post by:
Hello, I came across the following problem with integrity constraints and PL/pgSQL (PostgreSQL version used: 7.4.2): I defined the following tables, constraints and data: create table a (n...
0
7267
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.