I read rows from some mssql table via PHPs PDO.
Some rows, are brought twice, exactly same rows, with exactly the same id values
- This happens to specific rows. Each time I run my import script, the issue happens on the very sam开发者_Go百科e rows. For example, after bringing some 16,000 rows correctly, one row, the same one each time, is brought twice.
- The duplication occurs in a row. The line is brought, and the next fetch() request returns the very same row.
- When I run: select * from MY_TABLE where id='the problematic id' only one row is returned, not two
Any ideas what (the hell) can go on here?
Thank you very much guys
edit: The query that is being run:
select o.accountid, c.contactid, o.opportunityid, o.createdate, o.modifydate, o.createuser, o.modifyuser, o.description, o.projclosedate, o.notes, o.accountmanagerid
from sysdba.opportunity o
left join sysdba.opportunity_contact oc on o.opportunityid = oc.opportunityid and oc.salesrole = 'speaker' ";
left join sysdba.contact c on c.contactid = oc.contactid
where o.status <> 'Inactive'
order by o.opportunityid asc;
I think you need to join your contact
table to your opportunity
table. It seems that you might not have a 1 to 1 mapping between those tables the way you have it set up. See below:
--This should reference the "o" table but it doesn't.
left join sysdba.contact c on c.contactid = oc.contactid
If that's not the case then you should really be joining around the opportunity_contact
table instead (put it as your 'from' table).
精彩评论