How do I count the number of rows returned in my SQLite reader in C#?

前端 未结 11 2177
生来不讨喜
生来不讨喜 2021-01-11 13:10

I\'m working in Microsoft Visual C# 2008 Express and with SQLite.

I\'m querying my database with something like this:

SQLiteCommand cmd = new SQLiteC         


        
11条回答
  •  半阙折子戏
    2021-01-11 14:07

    Normally i would do

    select count(1) from myTable where word = '" + word + "';";
    

    to get the result as fast as possible. In the case where id is an int then it won't make much difference. If it was something a bit bigger like a string type then you'll notice a difference over a large dataset.

    Reasoning about it count(1) will include the null rows. But i'm prepared to be corrected if i'm wrong about that.

提交回复
热议问题