前提:
主委托与补送委托 编号一致,一个主委托可能有多个补送委托。查询时,先查主委托,再依次循环遍历其下的所有补送委托。
问题:
如何写 查询某个状态下委托的SQL?
解决方案:
SELECT COUNT(SUBMSTATE) As recordTotal
FROM submission
WHERE 1 = 1
and flag = '0'
and state = 0
and server = 120000000000
and bitand('2', location_to_bin(section)) = location_to_bin(section)
and submcode in (select su.submcode
from submission su
where su.state = '0'
and su.submstate = '0100'
and su.server = 120000000000); 注:flag='0'表示主委托