Group by query showing some unexpected results in List view android

后端 未结 2 421
醉梦人生
醉梦人生 2021-01-24 10:22

I have a List view in which I am showing received messages from contact numbers. Now the problem was that if i received 5 messages from \"1234567\" and 3 messages from \"56789\"

2条回答
  •  遇见更好的自我
    2021-01-24 11:08

    "select * from " + "smss" +  " group by " + "contactnumber" + " = \"" + "\"" ;
    

    This is not a valid SQL-Query This Query would render to

    "select * from smss group by contactnumber = "1234567"";
    

    What's missing here is the "where" operator. Your query should include this and thus look like this:

    "select * from smss where contactnumber = "1234567" OR contactnumber = "56789" group by contactnumber";
    

    Or to display it like you did:

    "select * from " + "smss" +  " where " + "contactnumber" + " = \"" + "1234567\"" + " OR " + "contactnumber" + " = \"" + "56789\"" + " group by " + "contactnumber";
    

提交回复
热议问题