• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

MySQL table joining

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ajith Mohan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok.. thanks .....
will try and let u know later..
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic