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

Come posso ottenere dati da due tabelle

Utilizzo di colonne fittizie per tenere conto delle diverse strutture e aggiungere un'unione per unirle:

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