Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

82
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda