我有联系人数据库 有行的表:
lastname text, firstname text, number text
我正在查询按字母顺序显示排序结果,“lastname”首先排序,“firstname”第二次排序,然后是“number”,我想列出其他最后有字段的人(下面)
目前我正在使用
select * from table order by lastname IS NULL,firstname IS NULL ,number IS NULL
但没有正确排序
答案 0 :(得分:1)
按列排序,不仅仅是“IS NULL”
select * from table
order by
lastname IS NULL, lastname,
firstname IS NULL, firstname,
number IS NULL, number
由于SQLite对0
使用FALSE
而1
使用TRUE
,因此空条目应该是最后的。见Boolean Datatype