All
I want to run an insert query to insert new records but only distinct one's.Is there any direct query syntax to do that.I have an idea to write a function to check the records one by one but that will be cumbersome if dataset is large.any other ideas??
thanks
Sree
4 15958
While in the query design view , click Properties on the toolbar to display the query's property sheet.
To prevent showing duplicate records in a query based on fields in the underlying table, Set the UniqueRecords property to yes. This would be SELECT DISTINCTROW if you were writing the SQL in VBA
To prevent showing duplicate records in a query based on fields in the query design grid, Set the UniqueValues property to yes. This would be SELECT DISTINCT if you were writing the SQL in VBA.
DonRayner
But my query is in the coding part and moreover its not a selection query its an insertion query.
thanks
Sree
@buddydasari
Sree,
Write your insert query and add either DISTINCT or DISTINCTROW after the SELECT statement. Here is an example of one of my own insert queries. -
INSERT INTO t_affectedJobs ( JobNumber, IssuedQuanity, IssuedDate, JobStatus, NCMRIdent )
- SELECT DISTINCT dbo_Material_Req.Job, -[Quantity] AS PickQuantity, dbo_Material_Trans.Material_Trans_Date AS Expr1, dbo_Job.Status, Forms!t_NCMaterial!idholder AS Expr1
-
FROM dbo_Material_Trans, dbo_Job RIGHT JOIN (dbo_Material INNER JOIN dbo_Material_Req ON dbo_Material.Material = dbo_Material_Req.Material) ON dbo_Job.Job = dbo_Material_Req.Job
-
WHERE (((dbo_Material.Material)=[Forms]![f_NonConformance_add]![NCBatchNumber]) AND ((dbo_Material_Trans.Lot)=[Forms]![f_NonConformance_add]![MaterialLotNumber]) AND ((dbo_Material_Trans.Tran_Type)="issue"));
-
NeoPa 32,556
Expert Mod 16PB @buddydasari
So you have two options. Both of which Don has already covered : - Change your SQL in the way indicated. Adding DISTINCT or DISTINCTROW (according to your needs) as a predicate after the SELECT keyword.
- Create the INSERT (append) query in the QBE grid and change the same properties as you would in a simple SELECT query.
When happy with the query use the SQL view to copy the resultant (working) SQL to your code. Sign in to post your reply or Sign up for a free account.
Similar topics
by: soni29 |
last post by:
hi,
i have a small question regarding sql, there are two tables that i
need to work with on this, one has fields like:
Table1:
(id, name, street, city, zip, phone, fax, etc...) about 20 more...
|
by: hoonew |
last post by:
I need to do in SQL the following psuedo-code, and I'm stuck:
IF ((COUNT(*) FROM a WHERE column_a=1)>0)
THEN
INSERT INTO TABLE b
ENDIF
|
by: Hi5 |
last post by:
Hi,
I am new to access I usedto work in Oracle and Mysql.
I am after a way that enables me to populate a database I designed in
access with lots of data which can be sorted in excel sheets,
...
|
by: Fred Zuckerman |
last post by:
Can someone explain the difference between these 2 queries?
"Select Distinct id, account, lastname, firstname from table1"
and
"Select DistinctRow id, account, lastname, firstname from table1"
...
|
by: Frank van Vugt |
last post by:
Hi,
Not exactly a showstopper, but I noticed this behaviour:
db=# create table f1 (id int, value int);
CREATE TABLE
db=# insert into f1 select 1 as id, null;
INSERT 25456306 1
|
by: new |
last post by:
I am building an effective dated file that shows results to date.
In part 1 of the select I
I process a larges set of input and genrate records for each date in the
processing period for which...
|
by: mivey4 |
last post by:
Okay I have 2 tables:
Table A - holds a list of new hardware serial numbers and their corresponding model (no constraints or indexes)
Table B - holds a distinct list of current serial numbers...
|
by: eighthman11 |
last post by:
Hi everyone:
Using Sql Server SQL 8
I'm trying to INSERT records into a "can software package" batch
table. I have a work-table that mimics the batch table. After
manipulating the records in...
|
by: omnittha |
last post by:
I would like to pull unique records of a SINGLE column but not the other related columns. When I use DISTINCT, it pulls up all the records which are unique across the columns. Here is the code.......
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |