SQL Command Operator IN, OR

30 views
Skip to first unread message

姚小新

unread,
May 10, 2017, 6:35:41 AM5/10/17
to FMDB
Hi all,

I found fmdatabase get different result from sql command below:

first set:
SELECT * FROM Table1  WHERE Col1=29 AND Col2 IN (308, 4073) AND Col3=0 AND Col4<>-9223372036854775808 ORDER BY Col5 DESC, Col6 DESC
SELECT * FROM Table1  WHERE Col1=29 AND (Col2=308 OR Col2=4073) AND Col3=0 AND Col4<>-9223372036854775808 ORDER BY Col5 DESC, Col6 DESC

second set:
SELECT * FROM Table1  WHERE Col1=29 AND Col2 IN (4073, 308) AND Col3=0 AND Col4<>-9223372036854775808 ORDER BY Col5 DESC, Col6 DESC
SELECT * FROM Table1  WHERE Col1=29 AND (Col2=4073 OR Col2=308) AND Col3=0 AND Col4<>-9223372036854775808 ORDER BY Col5 DESC, Col6 DESC

There is only Col2 order different.
But when Col2=308 first, the result will be Col2=308, without 4073.
In the other hand, when Col2=4073 first, the result will be Col2=4073 and without 308.

Does somebody have the same problem? How to resolve it?



姚小新

unread,
May 12, 2017, 5:38:41 AM5/12/17
to FMDB
Oh sorry, I found that the latter one will be delete somewhere.
So that's why I won't get the latter one's data.



姚小新於 2017年5月10日星期三 UTC+8下午6時35分41秒寫道:
Reply all
Reply to author
Forward
0 new messages