title: Cant ORDER BY or in a DESC order MySQLi
body: <p>I hope I'm not being to pushy, I tried using SQLYog and some other app for query building but let's face it, nothing beats the expertise of all of you. So here is I my question:
  Is it possible to order the results of this query in a manner that it's order by the most viewed (vistas.cuenta) And DESC?, You see vistas(viewed) is the table where php-mysql stored the amount of time an article is viewed (on a column named cuenta(count)), right now it's working but it presents them in the order of the Union. On the vistas table I have stores the ID of the article and a column that holds the table name for each table.</p>
  
  <p>In a two table scenarios it would be.</p>
  
  <pre><code>SELECT ciencia.id,ciencia.titulo,vistas.cuenta
  FROM vistas, ciencia
  WHERE vistas.id_pag = ciencia.id
  AND vistas.seccion = ciencia.tabla
  ORDER BY vistas.cuenta
  </code></pre>
  
  <p>That (the query up there) works perfect, but it doesn't work for the query below.</p>
  
  <pre><code>include("connection.php");
  $data = "
  SELECT ciencia.id,ciencia.titulo,vistas.cuenta FROM vistas, ciencia WHERE vistas.id_pag = ciencia.id AND vistas.seccion = ciencia.tabla
  UNION  SELECT cultura.id,cultura.titulo,vistas.cuenta FROM vistas, cultura WHERE vistas.id_pag = cultura.id AND vistas.seccion = cultura.tabla
  UNION  SELECT deportes.id,deportes.titulo,vistas.cuenta FROM vistas, deportes WHERE vistas.id_pag = deportes.id AND vistas.seccion = deportes.tabla
  UNION  SELECT economia.id,economia.titulo,vistas.cuenta FROM vistas, economia WHERE vistas.id_pag = economia.id AND vistas.seccion = economia.tabla
  UNION  SELECT internacionales.id,internacionales.titulo,vistas.cuenta FROM vistas, internacionales WHERE vistas.id_pag = internacionales.id AND vistas.seccion = internacionales.tabla
  UNION  SELECT migracion.id,migracion.titulo,vistas.cuenta FROM vistas, migracion WHERE vistas.id_pag = migracion.id AND vistas.seccion = migracion.tabla
  UNION  SELECT nacionales.id,nacionales.titulo,vistas.cuenta FROM vistas, nacionales WHERE vistas.id_pag = nacionales.id AND vistas.seccion = nacionales.tabla
  UNION  SELECT regionales.id,regionales.titulo,vistas.cuenta FROM vistas, regionales WHERE vistas.id_pag = regionales.id AND vistas.seccion = regionales.tabla
  UNION  SELECT politica.id,politica.titulo,vistas.cuenta FROM vistas, politica WHERE vistas.id_pag = politica.id AND vistas.seccion = politica.tabla
  ";
  $extractor = $mon -&gt; query($data);
  while($fila = mysqli_fetch_array( $extractor ))
  { print $fila['id'].' seccion '.$fila['titulo'].' - '.$fila['cuenta'].'&lt;br&gt;'; }
  </code></pre>