sql >> Base de Datos >  >> RDS >> Mysql

¿Cómo puedo obtener datos de dos tablas?

Usar columnas ficticias para dar cuenta de las diferentes estructuras y agregar una unión para unirlas:

SELECT * FROM (
    (SELECT article_id, title, article , NULL as cloudinary_id, NULL as url, user_id, created_on, 'article' as table_name  FROM article)
    UNION ALL
    (SELECT gif_id, title, NULL as article, cloudinary_id , url,  user_id, created_on , 'gif' as table_name  FROM gif)
) results
ORDER BY created_on ASC