From your details it looks like you have a column in database which you want to populate with the IDs (comma separated) entered by user.
At this point, your design does not seems to be much efficient. Rather than getting comma separated IDs you should create a separate table with Master/Child relationship to the existing one. So Instead of this:
Suppose,
--------------------
Table A (Your way)
--------------------
AutoID | IDs
1 | 1,2
2 | 1,2,4
3 | 3,4,7
It should be:
--------------------
Table Master (My Recommendation)
--------------------
AutoID | IDs
1 | 1 <--------- "AutoID" of "Table child"
2 | 2 <--------- "AutoID" of "Table child"
3 | 3 <--------- "AutoID" of "Table child"
--------------------
Table Child
--------------------
AutoID | IDs
1 | 1
1 | 2
2 | 1
2 | 2
2 | 4
3 | 3
3 | 4
3 | 7
It helps to manage data and make them easy to manipulate.
In case you can not change table structure, you need to update data by appending ID provided by user at the end, something like this: (Assuming SQL as backend)
update TableA set [Ids] = [Ids] + ',' + UserProvidedId
WHERE <condition>
So if first row of column [Ids] has '1,2' and users entered 3 then update statement will make it '1,2,3'.
Now you can see in this comma seperated design it is hard to find duplicates without doing a SPLIT or SUBSTRING.