Ask a Question related to Coldfusion Database Access, Design and Development.
-
kabbi~thkek #1
insert values only if they do not already exist in table
Hello I want to insert some values from one table (A) into another table (b).
However there are some values in table A which exist two times in table A. I
only want to insert values one time. So If a certain field value also exist in
some other row (same fieldname) then I don't want to insert it twice. It
doesn't matter which of the two rows will be inserted.
Can this be done with MySQL? Maybe with some Control Flow Functions?
Hopefully someone can help me.
Thank you in advance.
Gr, Kabbi
kabbi~thkek Guest
-
How Do you insert a table in Previous Table
How Do you insert a table in Previous Table that has an image, in a web page -
Login - multi table insert for registrant; subsquent login insert page requests into joined 'Selection' Table
Question regards insert and updates in sql server for a simple login script that requires registration the first time and only "email address" upon... -
insert values in an array
Hy all, I like to insert a value in an array but only want to renumber the ones after the inserted value like this; situation 1)... -
table does not exist error in AD query?
this runs perfectly as a .vbs but I'd like to convert it to an ASP... any ideas? Response.Buffer = True Dim objConnection, objCommand,... -
TEMP table comes into exist very slow
I have a piece of code like this SELECT SUM(col1) c1 From tbl GROUP BY col2 INTO TEMP tmp_tbl WITH NO LOG; Select AVG(c1) FROM tmp_tbl; My... -
Dan Bracuk #2
Re: insert values only if they do not already exist intable
use the keyword distinct in your select clause.
Dan Bracuk Guest
-
kabbi~thkek #3
Re: insert values only if they do not already exist intable
Hi Dan Bracuk,
Thank you for your answer! I already have another question about this. I also
do not want to insert values from A into B if they already exist in B.
I believe this should also be possible, do you perhaps know how?
Grt, Kabbi
kabbi~thkek Guest
-
kabbi~thkek #4
Re: insert values only if they do not already exist intable
Hi,
I used DISTINCT, however I now only get the values for that specific row I
used the distinct for (without any duplicates!!). However I want to get all
data(all columns) from a row but only the rows for where there is no duplicate
item in column G
SELECT *
FROM inventimport WHERE DISTINCT G
Will not work I guess?
kabbi~thkek Guest
-
BKBK #5
Re: insert values only if they do not already exist intable
I want to get all data(all columns) from a row but only the rows for where
there is no duplicate item in column G
A quick idea to get you started:
<cfquery name="myQuery1" datasource="myDSN">
SELECT G, count(*) as G_frequency
FROM inventimport
GROUP BY G
</cfquery>
<cfquery name="myQuery2" dbtype="Query">
SELECT G
FROM myQuery1
WHERE G_frequency < 2
</cfquery>
<cfquery name="myQuery3" datasource="#application.dsn#">
SELECT *
FROM inventimport
WHERE G in (#QuotedValueList(myQuery2.G)#)
</cfquery>
BKBK Guest
-
Dan Bracuk #6
Re: insert values only if they do not already exist intable
Originally posted by: kabbi~thkek
Hi,
I used DISTINCT, however I now only get the values for that specific row I
used the distinct for (without any duplicates!!). However I want to get all
data(all columns) from a row but only the rows for where there is no duplicate
item in column G
SELECT *
FROM inventimport WHERE DISTINCT G
Will not work I guess?
I said your select clause, not your where clause.
Dan Bracuk Guest
-
kabbi~thkek #7
Re: insert values only if they do not already exist intable
:) yes, thank you!!
kabbi~thkek Guest



Reply With Quote

