Ask a Question related to Coldfusion Database Access, Design and Development.
-
Photoshare #1
How to get All Records in Table A that don't havematching ID in Table B
I thought this would be a breeze, but I cannot seem to get it to work.
I have two tables (Table A) and (Table B).
(Table A) = all productid's (15,000 records)
(Table B) = Limited # of productid's (12,700 records)
I have had no success writing a query that will return ONLY the records from
Table A that do not exist in Table B. I have tried sub-queries and "Not Equal"
Joins but both seem to hang or crash MySQL. Does anyone know of code that
would work or is the amount of records to compare too large?
Thank you in advance.
Ron
[email]insight32@aol.com[/email]
Photoshare Guest
-
modify a field in all records of a table
I have a field 'time_zone' which is wrong in all records of my table 'mdl_users' and I would like to set this field to a unique value '1.0' in all... -
recordcount 0 but records in table
Hi, I'm getting an error on our search counter - division by zero not allowed - when I go past a certain date range . (CFSET) position (88:3) to... -
No records found for MySQL Table
Hello, We have a MySQL table that we had been using PHP to query, but now we want to query the table using CF 5.0 on a windows 2000 server. The... -
Could not load type VTFixup Table from assembly Invalid token in v-table fix-up table.
We are getting this error after clearing the web.config of database infomation - even after using the wizard to re-enter the information. I could... -
Delete from one table with matching records in another table
I'm an Access programmer making the migration to SQL Server, and I want to delete all the records from one table with matching records in another... -
reenaroy #2
Re: How to get All Records in Table A that don't havematching ID in Table B
Try this SQL
select * from tableA where id not in(select id from tableB)
reenaroy Guest
-
JMGibson3 #3
Re: How to get All Records in Table A that don't havematching ID in Table B
That example will work but might be pretty slow depending on DB, indexes, etc.
Your mission is usually accomplished with a "left join". Syntax depends on
your DB, for example, Oracle doesn't even use the Join keyword, they prefer a
(+) in the WHERE clause. If it's taking a long time, try a Left Join,
something like:
Select whatever from tblA
LEFT JOIN tblB on tblA.ID = tblB.ID
WHERE tblB.anycolumnatall IS NULL
JMGibson3 Guest
-
Dan Bracuk #4
Re: How to get All Records in Table A that don't havematching ID in Table B
Originally posted by: JMGibson3
That example will work but might be pretty slow depending on DB, indexes, etc.
Your mission is usually accomplished with a "left join". Syntax depends on
your DB, for example, Oracle doesn't even use the Join keyword, they prefer a
(+) in the WHERE clause. If it's taking a long time, try a Left Join,
something like:
Select whatever from tblA
LEFT JOIN tblB on tblA.ID = tblB.ID
WHERE tblB.anycolumnatall IS NULL
Oracle started supporting the join keyword with version 9i.
Your point about speed is valid though.
Dan Bracuk Guest
-
paross1 #5
Re: How to get All Records in Table A that don't havematching ID in Table B
What version of MySQL are you using? Older versions (before 4.1) did not allow
subqueries, which would explain a lot. If you are version 4.1 or later, then I
recommend using NOT EXISTS rather than NOT IN, as this is generally more
efficient (at least it is in Oracle).
Example:
SELECT a.productID, a.other_fields
FROM tableA a
WHERE NOT EXISTS( SELECT 1
FROM tableB b
WHERE a.productID = b.productID)
Phil
paross1 Guest



Reply With Quote

