On 20 January 2015 at 13:09, MikeSnow <michael.sab...@gmail.com> wrote: > I was wondering if anyone could help.... > I am trying to use Excel to create update statements based on certain > criteria. > For example...this works > UPDATE CDR_Adjusted SET "DateTime"=DATE||" "||TIME; > (This is what I need, a simple Concat > 2013-10-11 7:59 > But when I try to do this.... > > UPDATE CDR_Adjusted SET "DateTime" =( > SELECT [Column Name] > FROM Providers_Import > WHERE Provider = 'abc' > AND > Version = '2013-2014' > AND > [Column Name] = 'Date' > ) || Time ;"
The subquery can never return any value other than 'Date', so your update boils down to UPDATE CDR_Adjusted SET "DateTime" ='Date' || Time;" > > I get this.... > Date || Time > > Not the update, I would expect above > (In the table Providers_Input, the value in the [Column Name] is 'Date') You have not provided any information on sqlite version, or much about table schemas, but if I attempt something that looks similar (to me) I get: SQLite version 3.7.15.1 2012-12-19 20:39:10 Enter ".help" for instructions Enter SQL statements terminated with a ";" sqlite> sqlite> create table p( column_name text, provider text, version text ); sqlite> sqlite> insert into p values( 'ttt', 'xxx', 'blah' ); sqlite> insert into p values( 'Date', 'abc', '2013-2014' ); sqlite> insert into p values( 't2', 'abc', '2013-2014' ); sqlite> sqlite> select column_name from p where provider='abc' and version='2013-2014' and column_name='Date'; Date sqlite> sqlite> create table a( datetime text, time text ); sqlite> insert into a values( '', 'time1' ); sqlite> insert into a values( '', 'time2' ); sqlite> select * from a; |time1 |time2 sqlite> update a set datetime=(select column_name from p where provider='abc' and version='2013-2014' and column_name='Date') || Time; sqlite> select * from a; Datetime1|time1 Datetime2|time2 I.e. the result that I would expect... > > Thanks is advance Regards, Simon _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users