aspose file tools*
The moose likes JDBC and the fly likes MySQL table joining Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL table joining " Watch "MySQL table joining " New topic
Author

MySQL table joining

Ajith Mohan
Greenhorn

Joined: Nov 15, 2005
Posts: 3
hello,

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.

thanks in advance.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

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 ]

My Blog: Down Home Country Coding with Scott Selikoff
Ajith Mohan
Greenhorn

Joined: Nov 15, 2005
Posts: 3
hello 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.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Originally posted by Ajith Mohan:
pls give me a MySQl query.


Lol, demanding aren't we... here's a hint, try concat()
Ajith Mohan
Greenhorn

Joined: Nov 15, 2005
Posts: 3
ok.. thanks .....
will try and let u know later..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: MySQL table joining