Ciao a tutti. Avrei bisogno di creare una tabella di tipo view che mi unisca i dati di due tabelle diverse.
Le 2 tabelle da unire hanno anche dei campi duplicati.
La tabella di tipo view la chiamo "all_comments", mentre le 2 tabelle da unire si chiamano "commenti_ricette" e "commenti_news".
In pratica avrei bisogno che in ogni singola riga della tabella view andassero i dati di 2 righe delle tabelle
"commenti_ricette" e "commenti_news".
Ho provato così:
codice:
CREATE VIEW all_comments (id_x_link, data_commento, nome_utente, email_utente, ip_utente, testo_commento) AS SELECT commenti_news.id_commento_news || commenti_ricette.id_commento, commenti_news.data_commento_news || commenti_ricette.data_commento, commenti_news.nome_utente || commenti_ricette.nome_utente, commenti_news.email_utente || commenti_ricette.email_utente, commenti_news.ip_address || commenti_ricette.ip_adress_ricette, commenti_news.commento_news || commenti_ricette.commento_ricetta FROM commenti_news, commenti_ricette
E poi così
codice:
CREATE ALGORITHM = TEMPTABLE VIEW all_comments (id_x_link, data_commento, nome_utente,
email_utente, ip_utente, testo_commento) AS SELECT commenti_news.id_commento_news || commenti_ricette.id_commento, commenti_news.data_commento_news || commenti_ricette.data_commento, commenti_news.nome_utente || commenti_ricette.nome_utente, commenti_news.email_utente || commenti_ricette.email_utente, commenti_news.ip_address || commenti_ricette.ip_adress_ricette, commenti_news.commento_news || commenti_ricette.commento_ricetta FROM commenti_news, commenti_ricette
In entrambi i casi la query viene eseguita, ma viene fuori un risultato quasi vuoto, solo con alcuni 0
e 1 in alcuni campi.