Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as SQL by asdppiwi ( 8 years ago )
$sql_get_answers_options = "SELECT
    id,
    title,
    (
    SELECT
        COUNT(log_simple_questions.answer)
    FROM
        log_simple_questions
    JOIN(
        SELECT DISTINCT(clients_contact.phone),
            company_id,
            product_id,
            stage_id
        FROM
            clients_contact
    ) cc
ON
    cc.phone = log_simple_questions.phone_number
JOIN answers_options ao ON
    ao.code = log_simple_questions.answer AND ao.question_id = log_simple_questions.question_id
WHERE
    cc.company_id = 2 AND log_simple_questions.question_quee = 1 AND ao.id = answers_options.id AND cc.product_id = 1 AND cc.stage_id = 1
) AS counter,
(
    SELECT
        COUNT(log_simple_questions.answer)
    FROM
        log_simple_questions
    JOIN(
        SELECT DISTINCT(clients_contact.phone),
            company_id,
            product_id,
            stage_id
        FROM
            clients_contact
    ) cc
ON
    cc.phone = log_simple_questions.phone_number
WHERE
    cc.company_id = 2 AND log_simple_questions.question_quee = 1 AND cc.product_id = 1 AND cc.stage_id = 1
) total
FROM
    answers_options
WHERE
    question_id =(
    SELECT
    main.id
FROM
    simple_questions main
JOIN periodic_table pt ON
    main.id = pt.question_id
WHERE
    main.company_id = 2 AND main.code = 1 AND pt.stage_id = 1 AND pt.product_id = 1
)";

 

Revise this Paste

Your Name: Code Language: