如何执行 SQL 查询以从超过 1 个 table 中选择信息

How to execute SQL query for selection of info from more than 1 table

我想 select 根据另一个 table 的值 table

我有一个包含 'user' 信息 table 和 'appointment table' 的预订系统,它们有列:

  1. user_id, 姓名, 姓氏, telephone_number

  2. appointment_id, user_id, appointment_date_time

  3. 我想进行 SQL 查询,以便我可以选择一个日期,例如 5 月 20 日,并检索 5 月 20 日的所有预订,但在不同的时间,像 12:00、9:00、14:00、15:00、10:00 等等,因为它们没有在 table[=12= 中排序]

  4. 将约会时间排序为:9:00、10:00、12:00、14:00、15:00

  5. Select user_id 次来自 'appointments'

    的预订
  6. Select 通过 'user' table 的用户凭据,如姓名和 phone 号码

最后我将把它实现到管理面板中 这样当管理员会选择一个特定的日期 他们可以看到所有的约会预订、他们的时间以及预订的人。

你能告诉我我可以使用什么样的查询吗(最好是复杂的) 或者指导我使用有用且易于理解的资源?

SELECT appointments.appointment_index, appointments.appointment_time, users.name, 
users.surname, users.telnumber  
FROM users 
INNER JOIN appointments 
ON users.user_id = appointments.user_id
WHERE appointment_date = '$date'
ORDER BY appointment_time";