数据库:ACCESS
有如下查询:
update 电阻器 a LEFT JOIN [D:\company_lib\PartTableDB.mdb;pwd=123].resistor1 b ON a.Part_Number=b.Part_Number and a.Material_code_13= b.Material_code_13 set a.flg='红色' where b.Part_Number is null and b.Material_code_13 is null 目的是查找用户数据库中“电阻器”表与公司数据库“resistor1”表之间的不同记录。用两表的Part_Number字段和Material_code_13字段进行匹配,如果两个字段都不同,则认为是缺少元器件,并标记为“红色”。
为什么我上面的查询b.Part_Number is null and b.Material_code_13 is null 中的and不起作用,把其中一个匹配字段不同,另一个匹配字段相同的记录也给查出来了?
有如下查询:
update 电阻器 a LEFT JOIN [D:\company_lib\PartTableDB.mdb;pwd=123].resistor1 b ON a.Part_Number=b.Part_Number and a.Material_code_13= b.Material_code_13 set a.flg='红色' where b.Part_Number is null and b.Material_code_13 is null 目的是查找用户数据库中“电阻器”表与公司数据库“resistor1”表之间的不同记录。用两表的Part_Number字段和Material_code_13字段进行匹配,如果两个字段都不同,则认为是缺少元器件,并标记为“红色”。
为什么我上面的查询b.Part_Number is null and b.Material_code_13 is null 中的and不起作用,把其中一个匹配字段不同,另一个匹配字段相同的记录也给查出来了?
也就是使用:
b.Part_Number is null and b.Material_code_13 is null
和
b.Part_Number is null or b.Material_code_13 is null
查询出的结果竟然相同!很是郁闷!!
update 电阻器 a LEFT JOIN [D:\company_lib\PartTableDB.mdb;pwd=123].resistor1 b ON a.Part_Number=b.Part_Number or a.Material_code_13= b.Material_code_13 set a.flg='红色' where b.Part_Number is null and b.Material_code_13 is null
粗体是我改的。
这样修改后可以得到我想要的结果,就是所有匹配字段都不同的记录。
但是又出现了一个问题,就是数据量小的时候很快,数据量一大就死机了。而改回原来的and对于大数据量很快,但是查询出的结果却包含了不同的记录和相似的记录(即只要有一个字段不匹配就会查出来)。怎么办呀??????????
同一问题,加分贴给出原帖链接就行了,不要再次提问。