我有两个表,我想比较这两个表中两列。表f_product中的列reflow必须大于等于表f_line中的列lreflow。我使用的代码是
SELECT f_product.oiv,f_product.product,f_product.passive,f_product.pitch,f_product.reflow,f_line.lreflow,f_product.spi,f_product.scomp,f_product.pallet,f_product.printer,f_line.line
FROM f_product,f_line
WHERE f_product.passive=f_line.passive
AND f_product.pitch=f_line.pitch
AND f_product.spi=f_line.spi
AND f_product.pallet=f_line.pallet
AND f_product.printer=f_line.printer
AND f_product.reflow >= f_line.lreflow
AND oiv='PMLE4720A' .但是,display out结果并没有比较f_product.reflow和f_line.lreflow之间的列数据。例如,结果仍然列出了reflow=8和lreflow=10的结果,其中reflow小于lreflow的值。我的sql代码有什么错误吗?
发布于 2013-12-23 10:59:58
我猜这就是先知吧?有时,它会被实际where子句和使用where的隐式连接之间的歧义所混淆。我会将其重新转换为ansi sql连接:
SELECT
.....
FROM
f_product a INNER JOIN f_line b ON
(a.passive = b.passive AND
a.pitch =b.pitch AND
a.spi=b.spi AND
a.pallet=b.pallet)
where oiv='PMLE4720A'
and a.reflow >= b.lreflow 假设产品和生产线之间的关系是这样的,那么在这四个领域上合作是有意义的……
https://stackoverflow.com/questions/20736372
复制相似问题