Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
PHP searching from fixed rows

I have patient table with 1000+ patient records. All records are created by 5 admins. I have separated patients in patient table using admin_id column. When admin "A" login then he only can see those patient that created by him. Now i wanna search patient from patient table. My search result will be only form patient records those are created by admin "A";

MySQL query:

SELECT 
    *
FROM
    patient
WHERE
    admin_id = 36 AND fname LIKE '%test%'
        OR email LIKE '%test%'
        OR mobile LIKE '%test%'
ORDER BY ID DESC 

(Here I get result from all records but I need only from where admin_id = 36.)

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You have to put around the OR close a parentheses () so that the expression only is true when admin_id is 36 and the rest also is true

SELECT 
    *
FROM
    patient
WHERE
    admin_id = 36 AND (fname LIKE '%test%'
        OR email LIKE '%test%'
        OR mobile LIKE '%test%')
ORDER BY ID DESC 
over 4 years ago · Santiago Trujillo Relatório

0

Try:-

SELECT 
    *
FROM
    patient
WHERE
    (admin_id = 36 AND fname LIKE '%test%')
        OR (email LIKE '%test%')
        OR (mobile LIKE '%test%')
ORDER BY ID DESC 
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda