I have a table which contains say X rows and 10 columns. User has an option to edit any of the rows and columns and also he can add new rows and add details to it. He has a single button 'Save' and check开发者_JAVA百科 box upon every row. He can select the rows which he has edited and inserted using the check box and save it using the Save button.
Now my question is, consider the user has edited X-1 rows and inserted some 3 rows. and has selected only the edited and inserted rows. How can i insert and update at the same time when he clicks the 'Save' button.
P.S: I am using Java Script and SQLj.
A SQL query can have multiple queries usually divided by a semicolon (;).
INSERT INTO table_name VALUES (value1, valu2, value3); UPDATE table_name SET column1=value, column2=value2 WHERE some_column=some_value
This is in fact the answer to your question, assuming that you know how to get all edited fields from your table, and make a bunch of queries from that.
精彩评论