I’m NOT well versed in SQL or SQLITE.
I’m running a simple select and join statement. I’m basically pulling contacts from a sqlite3 database and dumping out into a csv, manually.
The problem I’m running into is, I’ve got names and ID’s in one table, phone numbers and labels in another. Where, label means “Mobile”, “Work”, etc.
So I’m joining where the name’s ID = to the phone number’s owner ID.
What I’m finding (and this makes perfect sense) is that if I have three phone numbers for one person, that one person shows up three times.
IE:
John Doe, 123-123-1234, Home, someInc
John Doe, 123-123-4321, Mobile, someInc
John Doe, 123-456-3214, Work, someInc
Now.. how do I, through the actual SQL statement itself, get results more like this:
John Doe, 123-123-1234, Home, someInc
123-123-4321, Mobile, someInc
123-456-3214, Work, someInc
Foo Barr, 987-654-3211, Home, anotherInc
[...]
Perhaps you want to flatten the table:
This puts each type of phone number in a separate column. You need to research all the different labels to get the right columns.
You can also put all the phone numbers into one field, something like “home:0001112222,work:33344455555: