Simon Slavin <slav...@bigfraud.org> wrote:

>
> On 7 Oct 2013, at 3:45pm, dean gwilliam <mgbg25...@blueyonder.co.uk> wrote:
>
> > sqlite> UPDATE itms SET std_nm=(SELECT std_nm FROM aliases as x WHERE 
> > raw_nm = x
> > .raw_nm);
>
> looking at it without the 'AS' ...
>
> UPDATE itms SET std_nm=(SELECT std_nm FROM aliases WHERE raw_nm = 
> aliases.raw_nm);
>
> I'm wondering whether you actually mean
>
> UPDATE itms SET std_nm=(SELECT std_nm FROM aliases WHERE raw_nm = 
> itms.raw_nm);
>
> or something like that.
>
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

sqlite> create table t (k integer primary key, d integer);
sqlite> insert into t (k) values (1);
sqlite> insert into t (k) values (2);
sqlite> insert into t (k) values (3);
sqlite> create table t2 (k integer primary key, d integer);
sqlite> insert into t2 (d) values (101);
sqlite> insert into t2 (d) values (102);
sqlite> select * from t;
k           d         
----------  ----------
1           <>        
2           <>        
3           <>        
sqlite> select * from t2;
k           d         
----------  ----------
1           101       
2           102       
sqlite> update t set d = (select d from t2 where t2.k = t.k);
sqlite> select changes();
changes() 
----------
3         
sqlite> select * from t;
k           d         
----------  ----------
1           101       
2           102       
3           <>        
sqlite> update t set d = null;
sqlite> update t set d = 103 where k = 3;
sqlite> select * from t;
k           d         
----------  ----------
1           <>        
2           <>        
3           103       
sqlite> update t set d = (select d from t2 where t2.k = t.k);
sqlite> select changes();
changes() 
----------
3         
sqlite> select * from t;
k           d         
----------  ----------
1           101       
2           102       
3           <>        
sqlite> update t set d = null;
sqlite> update t set d = 103 where k = 3;
sqlite> select * from t;
k           d         
----------  ----------
1           <>        
2           <>        
3           103       
sqlite> update t set d = (select d from t2 where t2.k = t.k) 
   ...> where t.k in (select k from t2);
sqlite> select changes();
changes() 
----------
2         
sqlite> select * from t;
k           d         
----------  ----------
1           101       
2           102       
3           103       


In the original post, the columns raw_nm and x.raw_nm
are the same column, so the condition is always true.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to