如何查询联系人的_id、姓名和电话号码?
我需要查询联系人“数据库”以查找具有电话号码的所有联系人,以及标识该特定联系人的任何 ID 值。如果联系人集合/数组包含 > 1 个特定联系人的电话号码,每个电话号码应包含在其自己单独的“记录”中;所以,我需要检索值,例如:
ID
1
NAME
Sam L. Clemens
PHONE
262.490.1835
ID
1
NAME
Sam L. Clemens
PHONE
209.286.1910
ID
2
NAME
John Steinbeck
PHONE
414.277.1902
ID
3
NAME
William Saroyan
PHONE
123.625.1914
IOW:
1, Sam L. Clemens, 262.490.1835
1, Sam L. Clemens, 209.286.1910
2, John Steinbeck, 414.277.1902
3, William Saroyan, 123.625.1914
有人知道如何检索这些值吗?
I need to query the Contacts "database" for all Contacts that have phone numbers, along with whatever ID value identifies that particular contact. If the Contacts collection/array contains > 1 phone number for a particular contact, each phone num should be contained in its own separate "record"; so, I need to retrieve values such as:
ID
1
NAME
Sam L. Clemens
PHONE
262.490.1835
ID
1
NAME
Sam L. Clemens
PHONE
209.286.1910
ID
2
NAME
John Steinbeck
PHONE
414.277.1902
ID
3
NAME
William Saroyan
PHONE
123.625.1914
IOW:
1, Sam L. Clemens, 262.490.1835
1, Sam L. Clemens, 209.286.1910
2, John Steinbeck, 414.277.1902
3, William Saroyan, 123.625.1914
Does anybody know how to retrieve these values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,指定您正在使用哪个数据库,以及您使用哪种结构来存储“超过 1 个电话号码”?
我看不出有什么困难。只需在您的电话列上指定它可以为空,当您查询时,只需检查该列中的内容,如果不为空,则继续采用其他值
编辑:
它应该看起来像这样:
从表中选择 (ID, NAME, PHONE),其中 PHONE <>无效的
First of all, specify which database you are using, also what kind of structure are you using for storing "more than 1 phone number"?
I don't see the difficulty. Just specify on your phone column that it can be null, and when you are querying just check for whatever is in that column and if not null, then proceed with taking other values
EDIT:
It should look something like this:
select (ID, NAME, PHONE) from Table where PHONE <> null