Hello, I was writing for some help with a problem that has me stumped.
I have two tables in a DB. Table1 = dailydelete Table2 = dailyfactors. dailyfactors is a list of dates and some corresponding information HML, SMB, UMD and Rf for each of these dates dates are NOT repeated in this table dailydelete is data for say 100 stocks for each of the dates in dailyfactors including price, return, etc. dates ARE repeated in this table, for each stock the table dailydelete has many more rows than the table dailyfactors. I want to add columns to dailydelete. I want to pull information from table dailyfactors corresponding to the date in each row in table dailydelete (I use varchar as some data may be missing or input as a character) The following is the code I use: ALTER TABLE dailydelete ADD COLUMN SMB varchar(11); ALTER TABLE dailydelete ADD COLUMN HML varchar(11); ALTER TABLE dailydelete ADD COLUMN UMD varchar(11); ALTER TABLE dailydelete ADD COLUMN Rf varchar(11); UPDATE dailydelete SET SMB = (SELECT dailyfactors.SMB FROM dailyfactors WHERE dailydelete.data = dailyfactors.Date), SET HML = (SELECT dailyfactors.HML FROM dailyfactors WHERE dailydelete.data = dailyfactors.Date), SET UMD = (SELECT dailyfactors.UMD FROM dailyfactors WHERE dailydelete.data = dailyfactors.Date), SET Rf = (SELECT dailyfactors.Rf FROM dailyfactors WHERE dailydelete.data = dailyfactors.Date) WHERE EXISTS (select * from dailyfactors WHERE dailydelete.data = dailyfactors.Date); I get the following error: Error: near "SET": syntax error I have tried many different combinations of the above statement, but keep getting a syntax error somewhere or the other. Can someone please help and point out what I am doing wrong? Thank you for your help.... Shantanu Namjoshi _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users