如何使用两个条件查询 SQLite 数据库?
我有一个关于员工的表,包含 3 列,如下代码:
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + DEPT
+ " TEXT NOT NULL," + NAME + " TEXT NOT NULL," + CITY + " TEXT NOT NULL);");
现在我只想显示同一部门和城市的员工(即胡志明市和销售部门的员工)。我怎样查询才能得到它?
I have a table about employee with 3 columns like following code:
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
+ " INTEGER PRIMARY KEY AUTOINCREMENT, " + DEPT
+ " TEXT NOT NULL," + NAME + " TEXT NOT NULL," + CITY + " TEXT NOT NULL);");
now I just want to show employees in the same both DEPT and CITY(e.i both employees in HCM City and Sales department). How can I query to get it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@DienTrinh,你说得对,请注意
AND
周围的空格。那应该对你有用。@DienTrinh, you had it right, note the spaces around
AND
. That should work for you.解决办法是:
The solution is: