I need to limit results of each column in 4 items only in MySQL

0

I'm using this select

SELECT 
    *
FROM
    (SELECT 
        *
    FROM
        clientescontatos t1
    WHERE
        codcliente = 'teste'
            AND tecnicoFlag = 1
    LIMIT 4 UNION ALL SELECT 
        *
    FROM
        clientescontatos t2
    WHERE
        codcliente = 'teste'
            AND outrosFlag = 1
    LIMIT 4 UNION ALL SELECT 
        *
    FROM
        clientescontatos t3
    WHERE
        codcliente = 'teste'
            AND financeiroFlag = 1
    LIMIT 4 UNION ALL SELECT 
        *
    FROM
        clientescontatos t4
    WHERE
        codcliente = 'teste'
            AND administrativoFlag = 1
            LIMIT 4 ) ;

Example: Administrative, Financial, Technical, Other In that order.

    
asked by anonymous 04.07.2018 / 20:55

0 answers