Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!