glug: RE:query con Mysql

cyberghandi cyberghandi@libero.it
Mer 1 Set 2004 10:40:02 CEST


 mi stò picchiando nell'inserimento dei dati da una vecchia tabella nelle
> nuove, dopo averne studiato e realizzato la normalizzazione.
> 
> Premesso che:
> 
> mysql> select * from agente;
> +-----------+------------+
> | id_agente | agente     |
> +-----------+------------+
> |         2 |            |
> |         3 | BARLA      |
> |         4 | GIORDANINO |
> |         5 | MASSIMO    |
> |         6 | PETRIELLO  |
> +-----------+------------+
> 5 rows in set (0.00 sec)
> 
> 
> e:
> 
> mysql> select agente from new_tbl GROUP BY agente;
> +------------+
> | agente     |
> +------------+
> | NULL       |
> | BARLA      |
> | GIORDANINO |
> | MASSIMO    |
> | PETRIELLO  |
> +------------+
> 5 rows in set (0.06 sec)
> 
> 
> non riesco a capire perchè questa query non funziona:
> 
> mysql> SELECT id_agente FROM agente WHERE (agente.agente =
> new_tbl.agente);
> ERROR 1109: Unknown table 'new_tbl' in where clause
> mysql>
> 
> Qualche suggerimento?

Se quello che vuoi fare è un join  devi nominare tutte le tabelle 
nell FROM 

select  agente.id_agente from agente,newtable where (agente.agente =
new_tbl.agente);

Oppure con la sintassi piu comoda fai un left join

select  agente.id_agente from agente left join newtable ;

per saperne di piu leggi qui :

http://dev.mysql.com/doc/mysql/en/JOIN.html

Ciao 

(D).A.v.i.d




Maggiori informazioni sulla lista glug