Question

Locked

SQlite

By Wizard-09 ·
I need help with a sqlite query, i pulled my phonebook from my Iphone and opened it with SQLite database broswer, now I need a string to query the DB, I need to view the names and numbers anyone got a SQL string for this as I in't got a clue

Update
table abperson (This table holds the names)
table abmultivalue (This table holds the numbers)

So what I want to do is query the DB to show both the names and numbers on one sheet make sence?

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

here ye go

by Shellbot In reply to SQlite

Ok, never used SQLLite, so presuming its pretty much the same as SQL regular.

Lets assume:
abperson - has columns called personid, firstname, lastname
and
abmultivalue - has columns called personid, phone number

(each table needs a column that matches to the other table (relation), reasoning says its
called something like personid, or contactid or something like that)

either of these 2 queries should work..I presume SQLLite allows joins.
You'll need to change your column names to suit what you have.
This will give you mor info than you need, but will show you how it works.

select p.personid, p.firstname, p.lastname, m.personid, m.phonenumber
from abperson p,abmultivalue m
where p.personid = m.personid


select p.personid, p.firstname, p.lastname, m.personid, m.phonenumber
from abperson p
inner join abmultivalue m
on p.personid = m.personid

Once you understand what I've done above, this is what you'll want:

select p.firstname, p.lastname, m.phonenumber
from abperson p
inner join abmultivalue m
on p.personid = m.personid

or

select (p.firstname + ' ' + p.lastname) as Name, m.phonenumber
from abperson p
inner join abmultivalue m
on p.personid = m.personid

or if you've only 1 name field:

select p.name, m.phonenumber
from abperson p
inner join abmultivalue m
on p.personid = m.personid

Collapse -

thanks

by Wizard-09 In reply to here ye go

shellbot, looked at what you wrote mod it to my needs and worked a treat thanks for the help and info

Collapse -

Coolio

by Shellbot In reply to thanks

Glad I was able to help :)

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums