GKChesterton
Programmer
MySQL 5.0.27, PHP 5.
I am inserting records into a table that already contains records. I don't want duplicates, so there's a unique index. Good query design should let me eliminate potential duplicates; but, I am getting the error "Duplicate entry ... for Key 1."
Shouldn't the ISNULL knock out the potential duplicates?
I'm new to MySQL, coming from MS Access. Maybe I'm having a syntax problem, perhaps with ISNULL. What's going wrong?
I am inserting records into a table that already contains records. I don't want duplicates, so there's a unique index. Good query design should let me eliminate potential duplicates; but, I am getting the error "Duplicate entry ... for Key 1."
Code:
INSERT INTO filter_cache
( [COLOR=red]fid_part[/color], pn_oem, descr_oem, )
SELECT DISTINCT
p.pid_part, p.pn_oem, p.descr
FROM (part p LEFT JOIN filter_cache fc
ON [COLOR=red]p.pid_part = fc.fid_part[/color])
INNER JOIN supplier_part_join sp
ON p.pid_part = sp.fid_part
WHERE [COLOR=red]ISNULL(fc.fid_part)[/color]
AND sp.pn_supplier LIKE '$search_str'
Shouldn't the ISNULL knock out the potential duplicates?
I'm new to MySQL, coming from MS Access. Maybe I'm having a syntax problem, perhaps with ISNULL. What's going wrong?
[purple]If we knew what it was we were doing, it would not be called
research [blue]database development[/blue], would it? [tab]-- Albert Einstein[/purple]