开发者

How can I insert data without deleting the existing record in MS Access?

I want to add a record into access. The column name is Names: Now I want to add data into existing data, without deleting o开发者_StackOverflow社区r adding the existing record

suppose:

id name     original name
1  blue       shoes   
2  black      shoes 
3  green      shoes

Now I want it like this suppose the record one is already there, and when user add the next two entries it should be like this

moreover: if a user send a new value to the column_name, so the value must be add to the name column without omitting the other value. If it is like blue and you send name value = black as a new value so it should look like blue black

id name    original name
1  shoes   blue black 

So how can I do this with an SQL statement


Something like this should do it

UPDATE tbl SET tbl.[original name] = tbl.[original name] + ' ' + @newName WHERE tbl.[name] = 'shoes'

You are losing all the relational goodness in the database however. So you probably want to take a long hard look at your design here and see if it can be improved (it almost certainly can).


update names set original_name = name where id = 1;

update names set name = "shoes" where id = 1;

and of course replace the id with the actual id and "shoes" with user input.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜