5

Can I add value to an int in a database without knowing its current value

 3 years ago
source link: https://www.codesd.com/item/can-i-add-value-to-an-int-in-a-database-without-knowing-its-current-value.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Can I add value to an int in a database without knowing its current value

advertisements

lets say I have the following table

players

player_id score
1       - 300
2       - 400

can I do a query that will add 10 to the score of a player?

because right now all I can think of is query the db, get the score, add 10 to it, then query the db and replace 300 with 310?

PS: Im new to SQL


You may try this:-

UPDATE players
SET score = score + 10
WHERE player_id = 1

Also check UPDATE in MySQL

Related Articles

Java Can I restore a two-dimensional array from a file without knowing its size?

Or is there any way to cast a generic object(that originally was a 2Darray) to a 2d Array without knowing its size? I have a program where the user enter data and that data is submitted into a 2D array that varies in size depending on how much the us

Can we deselect an empty pointer without knowing its type?

I have a question regarding the void pointer in c language. I would like to know Can we dereference a void pointer without knowing its type?You cannot. Dereferencing a void pointer requires an explicit cast beforehand. You can ofcourse cast it to any

Swift: Can not Add Value to Struct Dictionary Member

I can't add a value to a dictionary that is a member of a struct. For example, this: struct S { var d = [String:Int]() func f() { d["Hello"] = 0 } } results in this error: '@lvalue $T6' is not identical to '(String, Int)' Changing struct to clas

Can I add values ​​to the config.properties file by hand in Java

I want to keep a map of all the well known port numbers and it's associated services. I want to use the port number to get the protocol name. I don't want to use hashtable or map any anything like that. I'm thinking of properties file as a good candi

How can I add values ​​to Radio Buttons and calculate the answer?

I have a simpe form with 4 activities containing eight radio buttons. When one activity is answered, it goes to the next, and I want at the fourth activity to show the result of the radio buttons checked. Can somebody help me add values to the radio

can not add value to the SQL database

So Im reading in a RFID tag and wish to store the tag data into an sql database. I cannot get it to store in the RFID field of my sql database without manually placing single quote marks around the tag data. The RFID field is set to text in php myadm

I can not add records from the form to the database

I created Simple from with database Database: CREATE TABLE IF NOT EXISTS klient ( idklienta int(20) NOT NULL AUTO_INCREMENT, imie varchar(20) NOT NULL, nazwisko varchar(20) NOT NULL, nick varchar(20) NOT NULL, numer varchar(20) NOT NULL, email varcha

how can i add a new laravel site on a farm without destroying the environment?

How can i add a new site without running ? homestead destroy homestead up Im using Laravel Homestead version 2.0.13 When i add a new site, i add the following to my homestead.yaml file folders: - map: ~/web/code to: /code/websites sites: - map: larav

Can I add new custom tables to my aspnet database inside the asp.net MVC-5 project

I have the following:- Visual Studio 2013. i created a new asp.net MVC-5 web project. the project is using asp.net identity 2.2. for the authentication method i chose "Individual user accounts" this process created a new database named aspnet-Ou

How to add a nonzero column to the postgresql table without doubling its disk size

Is there a way to add a not null type column to a Postgresql table without doubling its size on disk? If for instance I have a table with some columns defined, and I want to add a column I'd do the following: alter table my_table add new_column int u

Can I create an instance of a class from AS3 by knowing its name?

Can I create an instance of a class from AS3 just knowing it's name? I mean string representation, like FlagFranceCreate instances of classes dynamically by name. To do this following code can be used: //cc() is called upon creationComplete private v

How can I insert a pandas data frame into the database without duplicating data?

I used .to_sql function to insert data. But it can't check duplicated insert data. (It only can check the duplicated tables) source code) when I run twice of the source code below. userData.to_sql(con=engine, name='test_quest_complete', schema='test'

How can I get XML subtags using a regex for its content without knowing its name

I have XML which looks like this when simplified: node_set = Nokogiri::XML(' <PARENT> <SOME_TAG>12:12:1222</SOME_TAG> <HOLY_TAG>12:12:1222</HOLY_TAG> <MAJOR_TAG>12:12:1222</MAJOR_TAG> <FOO_FOO>12:12:1222<

Can I add values ​​from a list to a spring property applicationContext.xml?

I am very new to spring and I am currently working on a program someone else has written years ago. Basically, the program is sending emails to a group that is referenced in the applicationContext.xml file as groupA. Now I retrieve other emails addre

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK