R
R
RaulDuke2016-11-15 10:09:47
MySQL
RaulDuke, 2016-11-15 10:09:47

Correct mysql query to Aster's call base?

Hello everyone, I am writing a micro-srm for a micro business, guys, help me formulate a request to the Aster call database. The database looks like this:
187e372472114fd8ae42efb2ead55a57.png
To receive calls, I make the following request:

SELECT * FROM calls WHERE (uniqueid,state) IN ( 
    SELECT uniqueid, MAX(state) /* выбираю записи с макс. state т.е. смотрю не все записи логгера астера, а только чем закончился тот или иной звонок (занятость (7), неответ (4), ответ абонента (6) и т.д. */
    FROM calls WHERE dst!=src /* в каждом звонке есть запись где звонящий = ответившему, они не нужны (насколько понимаю в этом месте "бриджится" звонок */
    GROUP BY uniqueid ) /* выборку по макс. стейту звонка делаем только внутри уникального айди вида 1479192928.2082 */
ORDER BY created DESC LIMIT 0,15

Look at the second part of the ID (marked in red) in one call, it is different and for the database these are different records, but I need to formulate a query so that the selection is made according to the first part (up to the dot) of the ID.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-11-15
@RaulDuke

SUBSTRING_INDEX()
But note that the number before the dot is the Unix Timestamp at the time the pipe was created. This number will be the same for all channels created in one second and, with active use of Asterisk, the same for unrelated channels.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question