我在下面提到了两个表格:
表1:
ID Value1 Value2 Value3 Remarks
RTE-10 2400.00 1.5 2300 Processed
RTE-11 1300.00 1.8 1750 Failed
RTE-12 1900.00 1.25 2000 Accepted
表2:
ID Read1 Read2 Read3 Status
RTE-10 2400.0 1.5 2300.25 Processed
RTE-11 1300.0 1.4 1900.22 Accepted
RTE-12 1600.0 1.20 2000.45 Processed
通过比较这两个表,我想获取那些值不匹配的行 Table1
至 Table2
(忽略十进制值)。
所需输出:
ID Value1 Value2 Value3 Remarks Read1 Read2 Read3 Status
RTE-11 1300.00 1.8 1750 Failed 1300.0 1.4 1900.22 Accepted
RTE-12 1900.00 1.25 2000 Accepted 1600.0 1.20 2000.45 Processed
我正在尝试下面提到的查询:
select * from Table1 t1
left join Table2 t2 on t1.ID=t2.ID
where t1.Value1!=t2.Read1
and t1.Value2!=t2.Read2
and t1.Value3!=t2.Read3
and t1.Remarks!=t2.Status
group by t1.ID;
1条答案
按热度按时间rks48beu1#
你可以试着用
CAST
作为UNSIGNED
忽略小数点的条件。架构(mysql v5.7)
查询#1
db fiddle视图