Mysql
 SQL >> Database >  >> RDS >> Mysql

Unire due tabelle con SQL

La query può essere simile a questa:

SELECT *
FROM movies m
INNER JOIN history h ON h.movie_id = m.id
WHERE h.user_id = $id
ORDER BY h.id;

Fai attenzione alla SQL injection: invece di inserire variabili direttamente nello statement, usa prepared statement con parametri bindati.