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

185
Visualizações
SQL query comparing data in two tables

So I'm still very new to databases. I have a table called patappts, where the name of the hygienist that will be serving the patient for each appointment is stored, among other things. When a user clicks on a date to sign up for an appointment it sends the start time of the appointment that was clicked through to my php file. What I'm trying to do is get the names of all my hygienists in my hygienists table that are not already in my patappts table with the same start time as the one that the user clicked. Therefore only showing the names of the hygienist's that don't already have an appointment at that time.

Not quite sure what to use in my query to achieve this.

$sql = "SELECT hyg FROM patappts WHERE start != '$start' UNION SELECT name FROM hygienists";
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Assuming that you have a hygenists table which contains the list of all the hygenists, I think the query you should use is

SELECT h.name
FROM hygenists h
WHERE h.name NOT IN (
    SELECT p.name
    FROM patappts p
)

This way you will select only those names who do not appear in the appointments list.

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