Joomla.it Forum
Non solo Joomla... => Database => : pippo30 09 May 2012, 15:58:59
-
vorrei riuscire a fare una unione di due tabelle tipo questa
La sintassi istruzione JOIN è la seguente
SELECT * FROM tab_uno
INNER JOIN tab_due ON tab_uno.campo = tab_due.campo
le due tabelle in questione sono queste:
Tabella utenti joomla
---Struttura della tabella `j17_users`
CREATE TABLE IF NOT EXISTS `j17_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`username` varchar(150) NOT NULL DEFAULT '',
`email` varchar(100) NOT NULL DEFAULT '',
`password` varchar(100) NOT NULL DEFAULT ''
tabella comunity bulder
CREATE TABLE IF NOT EXISTS `j17_comprofiler` (
`id` int(11) NOT NULL DEFAULT '0',
`user_id` int(11) NOT NULL DEFAULT '0',
`firstname` varchar(100) DEFAULT NULL,
`middlename` varchar(100) DEFAULT NULL,
`lastname` varchar(100) DEFAULT NULL,
`hits` int(11) NOT NULL DEFAULT '0',
`message_last_sent` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`message_number_sent` int(11) NOT NULL DEFAULT '0',
`avatar` varchar(255) DEFAULT NULL,
`avatarapproved` tinyint(4) NOT NULL DEFAULT '1',
`approved` tinyint(4) NOT NULL DEFAULT '1',
`confirmed` tinyint(4) NOT NULL DEFAULT '1',
`lastupdatedate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`registeripaddr` varchar(50) NOT NULL DEFAULT '',
`cbactivation` varchar(50) NOT NULL DEFAULT '',
`banned` tinyint(4) NOT NULL DEFAULT '0',
`banneddate` datetime DEFAULT NULL,
`unbanneddate` datetime DEFAULT NULL,
`bannedby` int(11) DEFAULT NULL,
`unbannedby` int(11) DEFAULT NULL,
`bannedreason` mediumtext,
`acceptedterms` tinyint(1) NOT NULL DEFAULT '0',
`cb_licenzauso` int(11) DEFAULT NULL,
`cb_citta` varchar(255) DEFAULT NULL,
`cb_applicativo` varchar(255) DEFAULT NULL,
pesavo di unire le due tabelle visto che ho la necessistà di avare dei compi che ho aggiuto io che mi servono.
Io uso un componente per fare sso con un'altra piattaforma moodle
quindi importo da li gli utenti ma poi perdo i seguenti campi che in jooma nn ci sono
cb_licenzauso` int(11) DEFAULT NULL,
`cb_citta` varchar(255) DEFAULT NULL,
cb_applicativo` varchar(255) DEFAULT NULL,
come posso fare???
l'intento è quello di unificare le tabelle è possibile???
mi serve fare questo perchè altrimenti in joomla perdo i campi
cb_licenzauso` int(11) DEFAULT NULL,
`cb_citta` varchar(255) DEFAULT NULL,
cb_applicativo` varchar(255) DEFAULT NULL,
aspetta una indicazione da seguire SALUTI
-
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('uno.*, due.*');
$query->from('#__tab_uno AS uno');
$query->join('LEFT', '#__tab_due AS due ON due.campo=uno.campo');
$db->setQuery($query);
$results = $db->loadObjectList();
print_r($results);
M.
-
secondo voi sono sulla strada giusta ??
-
come posso fare per creare la stessa situzione in joomla??
-
mi rispondo da solo funziona grazie a tutti
-
se posso devo chidere come faccio poi sucessivanente implementarlo in joomla (diversamente da come pensavo nn funziona