> Can someone please tell me what I'm doing wrong here? I want > this code to check for duplicates in a database and then give > the javascript error pop-up. However, when I add a unique > record it keeps giving me the duplicate pop-up message. > > <CFQUERY name="checkduplicates" datasource="pc_inventory"> > Select pcname, ip, serialnumber, oldpcnumber, newpcnumber > from inventory > Where id=id > </cfquery>
ID will always equal ID, so this query will match every record in the INVENTORY table. If you want to find duplicates, you'll need to do a self-join. Something like this might work - I obviously haven't tested it, though, and it usually takes me a couple of tries to write a query to detect duplicates. SELECT i1.pcname, i1.ip, i1.serialnumber, i1.oldpcnumber, i1.newpcnumber FROM inventory i1 INNER JOIN inventory i2 ON i1.id > i2.id WHERE i1.pcname = i2.pcname AND i1.ip = i2.ip AND i1.serialnumber = i2.serialnumber AND i1.oldpcnumber = i2.oldpcnumber AND i1.newpcnumber = i2.oldpcnumber Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:220919 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

