query.prepare("SELECT invoice FROM " + m_invoiceInfoTable + " WHERE invalid='' AND invoice IN (SELECT invoice FROM " + m_invoiceUserTable + " WHERE user=:user)");
此查询有问题吗? 我没有设置无效字段,仍然没有给出与
对应的任何记录答案 0 :(得分:2)
你想用
说什么?invalid=''
您是说无效被定义为空字符串,或者无效是空(未定义),这将是
invalid IS NULL
答案 1 :(得分:1)
试试这个:
query.prepare("SELECT invoice FROM " + m_invoiceInfoTable + " WHERE invalid is null AND invoice IN (SELECT invoice FROM " + m_invoiceUserTable + " WHERE user=:user)");
无法使用比较运算符测试NULL值,例如=,<或<>。
答案 2 :(得分:0)
试试这个:
SELECT invoice FROM " + m_invoiceInfoTable + "
WHERE ISNULL(invalid, '')='' AND invoice IN (SELECT invoice FROM " + m_invoiceUserTable + " WHERE user=:user)
什么是无效的数据类型,是char,string,bit还是int等等。它可以为空吗?