How to insert more data in a row cell

Hello i have this sql structure

Table (CS)
Rows( ID ,CLASS, DURATION ,CREDIT ,PROFESSOR ,STUDENT) there are many rows in the same structure just different ID and data. I am using java and im trying to make a sql query where students can input one class ID and when press submit their name is added on the STUDENT. So basically the STUDENT i want it to he always updated by having names added not replaced. Is it possible to do it? I tried to make a query that looks like this string sql = INSERT INTO CS (STUDENTS) WHERE ID = x VALUES(student_name);

Is it possible to be made such thing?

Thank you in advance.

If you are wanting to update a row and not add a new row, you use UPDATE not INSERT.

Sample SQL =
UPDATE myTableName SET FieldNameHere = 'Whatever You are Updating it to'
WHERE RowIdField = 12345

1 Like

First - you need to get the STUDENT id value - assuming that is from the STUDENT table. Then - you need to define the other data elements. Where do you get CLASS, DURATION, CREDIT, PROFESSOR from? How is the data in those columns defined?

Once you have that - then you can build an INSERT query to insert the data into the CS table.

1 Like

Welcome! Since we do not have access to your database you need to provide us some sample data. help us help you . here is an example. I purposely made all data types int, since you did not specify this in your question. You need to provide us the proper table structure, data type and sample data to help you

create table #cheesemelt(ID int ,CLASS int, 
DURATION int,CREDIT int,PROFESSOR  int,STUDENT int) 

insert into #cheesemelt
select 1, 2, 3, 4, 5, 6
1 Like