problems in the operation of the database mysql

Category: Web Develop
 
laolongdie
2008-12-01 10:59:33

Sponsored Links
In MYSQL inside a table as follows
creat table test {
{
name varchar (255),
stu_id varchar (255),
sex varchar (255),
class varchar (255),
data varchar (255)
}
now there are two lines are so
name = "xiaowang" stu_id = "1" sex = "2" class = null data = null
name = "xiaowang" stu_id = null sex = null class = "two" data = "1990"

I want to change the data inside
name = "xiaowang" stu_id = "1" ; sex = "2" class = "two" data = "1990"
when there are a lot of such information when
like to ask how easy it changed? I am using JSP + TOMCAT + MYSQL, ready to use web page is displayed.

Another problem is:
name = "xiaowang" stu_id = "200705" sex = "2" class = null data = " ; testtest "
We know stu_id = 200705 in 2007 indicates that in 2007 enrolled, 05 refers to is the five classes, meaning that second grade 5 classes, I now want two Grade 5 classes this information is saved to class on how easy to operate, we can give a good way opinions! Thank


Sponsored Links

anyexingkong
2008-12-01 11:17:31
You use an update statement
UPDATE test SET test.name = 'xiaowang', test.stu_id = '200705 ' , test.sex = '2 ', test.class =' ​​two ', test.date =' testtest '
WHERE test.id = test.id
where test.id I added to the proposed landlord in writing when they are coupled with each table a primary key. Easy access to change
xiejunming0755
2008-12-01 11:20:23


I think the landlord

UPDATE test SET test.name = 'xiaowang', test.stu_id = '2007050102 ', test.sex = '2', test.class = '05 ', test.date = '2007'
WHERE test.id = test.id

Dawn stu_id just a primary key id only, not suitable for storing more specific business data, or use the class to store the class, date Year to store it. '
Recommend only the primary key as a unique serial number label, where the encoding logic, not as a business data processing.
sunny7374
2008-12-01 11:40:22
If it is a lot of updates, then it can be used in another class jdbc PreparedStatement to achieve, where you can update multiple data records.
lcngame
2008-12-01 11:58:59
everyone how much support, if not understand what I mean please say it Well
CVV000111
2008-12-01 12:17:28
I use is PreparedStatement, there are other better way to do this?
dlp15
2008-12-01 12:26:22
I have here is a lot of updates, oh, do you have any good way to do
ldqhw
2008-12-01 12:30:27
you help me
fangw2009
2008-12-01 12:47:03
How much support! We look forward to a good way
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.