Re: [sqlite] insert help
Jean-Christophe Deschamps-3 wrote: > > >>My date column is set when the program starts and i do not want it to >>change. > > How is this date column set in the database without inserting anything? > >> So I have my with and two columns and >>. I have say 5 values (1 2 3 4 5) that I wanted inserted >>into mytable where the date is equal to date that was preset my >>starting the >>program. > > Preset, how? I guess you have this date stored in some variable > somewhere. Just use it to fill the date column in the each new row. > >> So a select of my table would look like this: >>select * from mytable where date='2011/04/18 21:35:33'; >>2011/04/18 21:35:33|1 >>2011/04/18 21:35:33|2 >>2011/04/18 21:35:33|3 >>2011/04/18 21:35:33|4 >>2011/04/18 21:35:33|5 > > So you need to perform as many inserts as values you have to insert: > insert into mytable (date, value) values ('2011/04/18 21:35:33', 1); > insert into mytable (date, value) values ('2011/04/18 21:35:33', 2); > insert into mytable (date, value) values ('2011/04/18 21:35:33', 3); > insert into mytable (date, value) values ('2011/04/18 21:35:33', 4); > insert into mytable (date, value) values ('2011/04/18 21:35:33', 5); > > If you have really _many_ inserts to perform, wrap the lot in a > transaction to speed up the process: > begin; > > commit; > > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > that worked perfect. thanks for the help. Do you think a join would be better then a insert? -- View this message in context: http://old.nabble.com/insert-help-tp31429185p31434954.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] insert help
Jean-Christophe Deschamps-3 wrote: > > >>Newbie here. i'm trying to insert multiple values into a table by a >>certain >>date and when I use where clause it fails. This is my code "insert >>into db >>(table) values ('value') where date = 'date range'". Thanks for any help. > > There is no where clause in insert statements, it wouldn't make sense. > Your insert should look like: > > insert into mytable (datecolumn) values > (litteral_date_in_the_format_you_choose); > > See http://www.sqlite.org/lang_insert.html > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > My date column is set when the program starts and i do not want it to change. So I have my with and two columns and . I have say 5 values (1 2 3 4 5) that I wanted inserted into mytable where the date is equal to date that was preset my starting the program. So a select of my table would look like this: select * from mytable where date='2011/04/18 21:35:33'; 2011/04/18 21:35:33|1 2011/04/18 21:35:33|2 2011/04/18 21:35:33|3 2011/04/18 21:35:33|4 2011/04/18 21:35:33|5 -- View this message in context: http://old.nabble.com/insert-help-tp31429185p31433593.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] insert help
Newbie here. i'm trying to insert multiple values into a table by a certain date and when I use where clause it fails. This is my code "insert into db (table) values ('value') where date = 'date range'". Thanks for any help. -- View this message in context: http://old.nabble.com/insert-help-tp31429185p31429185.html Sent from the SQLite mailing list archive at Nabble.com. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users