Search
 
SCRIPT & CODE EXAMPLE
 

SQL

how to view full conversation with chat.db

select
 m.rowid
,coalesce(m.cache_roomnames, h.id) ThreadId
,m.is_from_me IsFromMe
,case when m.is_from_me = 1 then m.account
 else h.id end as FromPhoneNumber
,case when m.is_from_me = 0 then m.account
 else coalesce(h2.id, h.id) end as ToPhoneNumber
,m.service Service

/*,datetime(m.date + 978307200, 'unixepoch', 'localtime') as TextDate -- date stored as ticks since 2001-01-01 */
,datetime((m.date / 1000000000) + 978307200, 'unixepoch', 'localtime') as TextDate /* after iOS11 date needs to be / 1000000000 */

,m.text MessageText

,c.display_name RoomName

from
message as m
left join handle as h on m.handle_id = h.rowid
left join chat as c on m.cache_roomnames = c.room_name /* note: chat.room_name is not unique, this may cause one-to-many join */
left join chat_handle_join as ch on c.rowid = ch.chat_id
left join handle as h2 on ch.handle_id = h2.rowid

where
-- try to eliminate duplicates due to non-unique message.cache_roomnames/chat.room_name
(h2.service is null or m.service = h2.service)

order by m.date desc;
Comment

PREVIOUS NEXT
Code Example
Sql :: tabular function in sql server 
Sql :: yesql 
Sql :: oracle query archivemode 
Sql :: MQL4 mql4 run ea on all symbols by adding to just one chart 
Sql :: SQL single column 
Sql :: updating mysql 
Sql :: select concat alter table mysql 
Sql :: sql select rows between 1000 and 2000 
Sql :: oracle user used size 
Sql :: oracle string substitution 
Sql :: update values in select statement sql 
Sql :: apache2 ssl error 
Sql :: postgresql get tables where column is foreign key 
Sql :: indexes sql 
Sql :: union in sql 
Sql :: how to select multiple columns in sql 
Sql :: how to query a db sqlite3 database in django python 
Sql :: mysql select all columns and specific fields as 
Sql :: mysql extract days 
Sql :: MAKE TABLE FIT in oracle sql 
Sql :: select all domains of database firbird 
Csharp :: how to load the active scene unity 
Csharp :: wpf round button 
Csharp :: how to check the tag of a collider in unity 
Csharp :: c sharp split by newline 
Csharp :: how to print a variable in c# with text 
Csharp :: wpf bind to self 
Csharp :: c# generate random date 
Csharp :: Linq - Random Elements 
Csharp :: c# datetime current 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =