This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
how can i take the combined values of two columns in a table, and insert it to a new column in the same table. All the rows have to be fetched. Only one column always have the value. the corresponding second column, may or may not have the value.if two columns have value, i want to combine those and insert into a new column,else have to insert the available(column 1)data to the new column.
What exactly are you asking? How does one accomplish this with a stored procedure and/or database triggers and/or using java and jdbc?
If your asking how do you create a new column in a table, you first alter the table by using the SQL "ALTER TABLE <NAME> ADD Column <DETAILS>" either somewhere in your SQL code or via the JDBC interface. As for 'inserting' the values into a record, this is misleading terminology. You 'insert' rows/records into a table, you do not typically use the word 'insert' when adding data INTO a column. To clarify, the 'insert' of the column is only done once when you alter the table. After which, you have to then 'update' each row.
Hope this clarifies a few things. [ November 16, 2005: Message edited by: Scott Selikoff ]
i will explain my need once again. i have a table with few fields, including, field 'A' and 'B'. i have updated the table with a new field, say 'newField'. i want to take the values of 'A' and 'B' as a single data (combined data), and put to 'newField'. there are many rows in the table, so the query must affect all rows. Field 'A' will always have values, but field 'B', sometimes have values.if both have have values, both must be combined, else the available data must be updated to the 'newField' for this purpose .hope now u r clear with my question. pls give me a MySQl query.