-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchat.sql
More file actions
28 lines (28 loc) · 1.1 KB
/
Copy pathchat.sql
File metadata and controls
28 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
SELECT
datetime((m.ZMESSAGEDATE + 978307200), 'unixepoch') AS date,
pn_from.ZPUSHNAME AS fromNICKNAME,
pn_to.ZPUSHNAME AS toNICKNAME,
REPLACE(REPLACE(m.ZFROMJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') AS fromNUMBER,
REPLACE(REPLACE(m.ZTOJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') AS toNUMBER,
m.ZTEXT AS message,
CASE
WHEN m.ZFROMJID IS NULL THEN 'OUT'
ELSE 'IN'
END AS direction
FROM
ZWAMESSAGE m
LEFT JOIN
ZWAPROFILEPUSHNAME pn_from ON pn_from.ZJID = m.ZFROMJID
LEFT JOIN
ZWAPROFILEPUSHNAME pn_to ON pn_to.ZJID = m.ZTOJID
WHERE
datetime((m.ZMESSAGEDATE + 978307200), 'unixepoch') > '2014-05-27'
AND datetime((m.ZMESSAGEDATE + 978307200), 'unixepoch') < '2014-12-31'
AND (
REPLACE(REPLACE(m.ZFROMJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') LIKE 'xxx%'
OR REPLACE(REPLACE(m.ZTOJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') LIKE 'xxx%'
OR REPLACE(REPLACE(m.ZFROMJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') = 'xxx'
OR REPLACE(REPLACE(m.ZTOJID, '@s.whatsapp.net', ''), '@g.us', ' (Group)') = 'xxx'
)
ORDER BY
m.ZMESSAGEDATE ASC;