Mysql
 sql >> Database >  >> RDS >> Mysql

PHP/SQL:utilizzando solo una query, SELECT righe da due tabelle se i dati sono in entrambe le tabelle, o semplicemente SELECT da una tabella in caso contrario

SELECT  ratings_stats.votes, 
        ratings_stats.total_value,
        ratings_stats.view, 
        ratings_stats.fav, 
        ratings_stats.wish,
        ratings_external.votes, 
        ratings_external.total_value
FROM  ratings_external
LEFT JOIN ratings_stats ON ratings_stats.imdbID = ratings_external.imdbID
WHERE ratings_external.imdbID = ?
LIMIT 1