anon271334
anon271334

Reputation:

Updating record in Database

I have this form on my site where a user can enter many strings and save it to their account. But I'm not sure how to go about it.

Instead of creating a whole new user, with new values, I'd just like to update a single entry in the database.

For example if a user wanted to add another email address to their account, how would I sort of create an array, and add that to their existing space in the database?

Thank you

Upvotes: 1

Views: 104

Answers (4)

u11
u11

Reputation: 97

i had a project similar to that and stored the input in a CSV format.

"[email protected]","[email protected]"

then you can use this function to convert the CSV string to an array for manipulation in php

Upvotes: 0

ErikE
ErikE

Reputation: 50201

INSERT PersonValues (PersonID, ValueTypeID, Value)
SELECT 234, 118, '[email protected]'
-- for person 234, insert value type 118 (email address) with said email address

For more information on this type of storage see EAV database.

Upvotes: 0

Dane
Dane

Reputation: 9827

You could store the field as XML (SQL Server works well with it) if you want something more structured than a simple list. This breaks normalization rules, of course, and complicates your application slightly (having to parse that field when you fetch rows, and having to build it when updating rows), but that's a choice you have to make for yourself.

Upvotes: 1

anishMarokey
anishMarokey

Reputation: 11397

are you looking for Update query in SQL

UPDATE [Cube].[dbo].[IdentityCheck]
   SET [Name] = <Name, text,>
 WHERE <Search Conditions,,>

Upvotes: 0

Related Questions