SQLite select where empty?

后端 未结 4 482
春和景丽
春和景丽 2021-01-29 23:33

In SQLite, how can I select records where some_column is empty?
Empty counts as both NULL and \"\".

4条回答
  •  鱼传尺愫
    2021-01-29 23:51

    You can do this with the following:

    int counter = 0;
    String sql = "SELECT projectName,Owner " + "FROM Project WHERE Owner= ?";
    PreparedStatement prep = conn.prepareStatement(sql);
    prep.setString(1, "");
    ResultSet rs = prep.executeQuery();
    while (rs.next()) {
        counter++;
    }
    System.out.println(counter);
    

    This will give you the no of rows where the column value is null or blank.

提交回复
热议问题