title: MYSQL : How to SELECT DISTINCT from multiple databases
body: <p>I've got problem when i want to display my data from multiple databases. It gives duplicate values.</p>
  
  <p>So I have three databases in the same server. They have same table structure.
  So here is my query :</p>
  
  <pre><code>Query = 'SELECT id_movie, movie_tittle
            FROM (SELECT id_movie, movie_tittle, status from margoplatinum.movie
        UNION
        SELECT id_movie, movie_tittle, status from detos21.movie
        UNION
        SELECT id_movie, movie_tittle, status from plaza21.movie) AS a
        WHERE a.status = "Now Playing"'
  </code></pre>
  
  <p>It works but gives the duplicate values like this :</p>
  
  <pre><code>id_movies      |        movie_tittle
  ------------------------------------------
        2        |          THOR 2
        1        |         Gravity
        3        |          THOR 2
        1        |  The Legend of Hercules
        4        |         Gravity
  </code></pre>
  
  <p>So I put the <code>DISTINCT</code> clauses like this :</p>
  
  <pre><code>Query = 'SELECT id_movie, DISTINCT (movie_tittle)
            FROM (SELECT id_movie, movie_tittle, status from margoplatinum.movie
            UNION
        SELECT id_movie, movie_tittle, status from detos21.movie
        UNION
        SELECT id_movie, movie_tittle, status from plaza21.movie) AS a
        WHERE a.status = "Now Playing"'
  </code></pre>
  
  <p>But the query above didn't work. It has an error message : </p>
  
  <pre><code>#1064 - You have an error in your SQL syntax; 
  check the manual that corresponds to your MySQL server version 
  for the right syntax to use near 'DISTINCT (movie_tittle) 
  FROM (SELECT id_movie, movie_tittle, status from mar' at line 1
  </code></pre>
  
  <p>So how to write the SELECT DISTINCT from multiple databases?</p>
  
  <p>Any help from you would be very helpful :)
  Thank you</p>