• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update SQL databse table

 
sunita shaw
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to update all the datas of one of the column of a table in my SQL database. I am using cpanel tool to manage/keep a track of my database.I exported the data in an excel sheet/CVS and have already modified it .How do I import the sheet back into that table such that it updates just that column.
I have to manage my site.Kindly let me know asap.

Thanx
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really a JDBC question, however: what database do you use? Can't you just use SQL directly to update you data? Why do you export your data first?
 
sunita shaw
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to update my column say(phone-number) for all the cusomers.How can i change all the phone numbers by running just one query.So I exported it in the form of an excel/cvs sheet & then easily modified the column & now how do i import it back so that just that column is modified.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair enough - you can't do that with just one statement (unless you are changing every 'phone number to be the same). Obviously, you could do it with a bunch of SQL statements though.

I still can't help much more though, unless you tell us which database you are using.
 
sunita shaw
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Peter for ur immediate reply..Okay can u help me out with this...

what is the query to update a column of a table by 5%
e.g:
Tablename roduct
Column name : Sale

So now I want to update Sale column by 5% so there is a query to do that.
Kindly let me know as I am getting error with this one:

UPDATE table Product SET Sale = ((Sale * 5)/100);
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sunita shaw:
So now I want to update Sale column by 5% so there is a query to do that.
Kindly let me know as I am getting error with this one:

UPDATE table Product SET Sale = ((Sale * 5)/100);

Remove the word "table". This is really an SQL question, that doesn't have anything to do with Java or JDBC. You'd better ask this to an SQL expert instead of on a Java forum.

Your SQL statement is going to set the value of column Sale to 5% of the original value, for all rows. Is that really what you want? Or did you want to increase the Sale values by 5% (i.e., set the value to 105% of the original value)?

UPDATE Product SET Sale = ((Sale * 105)/100);
[ December 01, 2005: Message edited by: Jesper de Jong ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33674
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that it is perfectly fine to ask SQL questions here. It's even in the forum description! Some people have gotten answers to complex SQL questions in this forum recently.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic