Showing posts with label adding. Show all posts
Showing posts with label adding. Show all posts

Sunday, February 19, 2012

Appending info into a column

How would you go about adding info to a column.

ex. There are 3 tables where all of the information is the same except the last column. The last column contains different types.

The tables are formatted something like

Name|Phone|Coverage|AA
Name|Phone|Coverage|BB
Name|Phone|Coverage|CC

But I want to have one table that contains the info as

Name|Phone|Coverage|AA|BB|CC|

| = Column changeJoin (possibly outer join) the 3 tables on the common columns.|||Name|Phone|Coverage|AA|BB|CC|

But are you not going to have a record for each type here also?|||I am not even sure how to word this. I tried the join and made sure to connect all of the tables to the most important information. Then I only output the AA, BB, CC columns. So in essence I have 3 free standing columns that are based on the same ID.

Here comes the problem. How do I match these columns with their related row.

I would like to take these 3 columns and append them to the end of the row with the corresponding information.

ex. I have AA|BB|CC and have Name|Number|Date

and want to have Name|Number|Date|AA|BB|CC

(the original rows looked something like my original post description)

but not all rows that had a BB correspond to a row with AA and would I want them to end up looking like this

ex. Name|Number|Date| |BB|CC

I know this is confusing, but I think it is coherent.

Please help!

Originally posted by andrewst
Join (possibly outer join) the 3 tables on the common columns.

Append to a field in a database

Hey guys,
I am working on some ASP stuff, and I have an html table which displays records from a SQL table.There is one field for adding notes which i want to append to. Basically I have a textbox, in which if a user enters information, it should be appended to a field (rNotes) in my database table. Right now all i can get it to do is overwrite the current information as i'm using an UPDATE query. Any ideas?In update statement you should use:

Update table_name set
column_name = column_name + new_data
where ....|||

Quote:

Originally Posted by nikhil86

Hey guys,
I am working on some ASP stuff, and I have an html table which displays records from a SQL table.There is one field for adding notes which i want to append to. Basically I have a textbox, in which if a user enters information, it should be appended to a field (rNotes) in my database table. Right now all i can get it to do is overwrite the current information as i'm using an UPDATE query. Any ideas?


Personally, I would create a notes table, and add records. This way, you can also store things like date/time, user id, etc. You can then just display them in sequential order. I do this with ASP all the time. Just did it yesterday, as a matter of fact. The client loved it.

Good luck,

Michael C. Gates