Back to top

Autore Topic: Unire campi di più tabelle --- join  (Letto 2147 volte)

pippo30

  • Visitatore
Unire campi di più tabelle --- join
« il: 09 Mag 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
« Ultima modifica: 09 Mag 2012, 16:19:00 da pippo30 »

mau_develop

  • Visitatore
Re:Unire campi di più tabelle --- join
« Risposta #1 il: 09 Mag 2012, 17:28:14 »
Codice: [Seleziona]
$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.

pippo30

  • Visitatore
Re:Unire campi di più tabelle --- join
« Risposta #2 il: 09 Mag 2012, 17:46:04 »
secondo voi sono sulla strada giusta ??

pippo30

  • Visitatore
Re:Unire campi di più tabelle --- join
« Risposta #3 il: 10 Mag 2012, 11:06:15 »
come posso fare per creare la stessa situzione in joomla??

pippo30

  • Visitatore
Re:Unire campi di più tabelle --- join
« Risposta #4 il: 10 Mag 2012, 11:13:10 »
mi rispondo da solo funziona grazie a tutti

pippo30

  • Visitatore
Re:Unire campi di più tabelle --- join
« Risposta #5 il: 10 Mag 2012, 15:14:48 »
se posso devo chidere come faccio poi sucessivanente implementarlo in joomla (diversamente da come pensavo nn funziona

 



Web Design Bolzano Kreatif