我想在sql-alchemy中运行以下查询
SELECT COUNT(*) FROM tableName AS T1,tableName AS T2
WHERE T1.col1 = T2.col1 AND T1.col2 = T2.col2
AND T1.col3 != T2.col3;
我尝试过:
db.session.query(Label,Label)
.filter(Label.surgery == Label.surgery)
.filter(Label.xray == Label.xray)
.filter(Label.user_id != Label.user_id).count()
但是,每当我知道测试数据库中应该为6时,才每次获得0。这种查询在Sql-alchemy中可能吗?