如何使用MySql从数据库的两个表中获取数据

时间:2019-05-17 14:24:18

标签: mysql sql

我想要做的是从一个表中获取所有信息,其中用户名和数字与表中的用户名和数字相同,然后在同一调用中,我想使用与标题为“ title”的第一行相同的标题(希望我已经很清楚了)。

尝试过:

`SELECT * FROM movies_in_theater 
     WHERE username = "${req.username}" 
     AND theater_number = '${req.theater}'
     LEFT JOIN movie_info.key_exp, movie_info.key_exp_time 
     WHERE movies_in_theater.movie_title = movie_info.title
     `

1 个答案:

答案 0 :(得分:0)

赞:

SELECT t.username
     , t.theater_number
     , t.movie_title
     , i.key_exp
     , i.key_exp_time

  FROM movies_in_theater t

  LEFT
  JOIN movie_info i
    ON i.title = t.movie_title

 WHERE t.username       = ?
   AND t.theater_number = ?