Look at this SQL, you can solve some problems

zhaozj2021-02-16  53

When I have a field in a table, it is used to store a series of transactions 00000 (there are four states representing the transaction), or there may be 2 states, and each time a transaction will change the corresponding status bit to 1, when all After the transaction is executed, the corresponding transaction is reset back to the initial state.

Use the following SQL to find all the completed states

Select * from tablename where field like '% 1%' and not field like '% 0%

Another way of writing

Select * from Tablename WHERE Charindex ('0', Field, 0) <1

转载请注明原文地址:https://www.9cbs.com/read-18907.html

New Post(0)