MARC
Mailing list ARChives |
FOLDOC
Computing Dictionary |
|
|
Incrementing/De-Incrementing columns |
Title: Incrementing/De-Incrementing columns
Contributor: Bamse
Last Update: Saturday September 2 21:15 EDT 2000
# Here is a MySQL columns drill for you to follow.
#
mysql -uroot -p
CREATE DATABASE TestDB;
USE TestDB;
CREATE TABLE test_table (
test_id INT NOT NULL auto_increment,
var_test VARCHAR(255) NOT NULL,
int_test SMALLINT NOT NULL,
PRIMARY KEY(test_id),
KEY(var_test),
KEY(var_test)
);
SELECT * FROM test_table;
INSERT into test_table (var_test,int_test) VALUES ('1', '1');
SELECT * FROM test_table;
UPDATE test_table SET var_test = var_test+2 WHERE test_id = '1';
UPDATE test_table SET int_test = int_test+2 WHERE test_id = '1';
SELECT * FROM test_table;
UPDATE test_table SET var_test = var_test-1 WHERE test_id = '1';
UPDATE test_table SET int_test = int_test-1 WHERE test_id = '1';
SELECT * FROM test_table;
UPDATE test_table SET int_test=int_test*2, int_test=int_test+1;
SELECT * FROM test_table;
UPDATE test_table SET int_test=var_test*2, int_test=int_test-1;
SELECT * FROM test_table;
DROP DATABASE TestDB;
quit
# Note that "DROP DATABASE TestDB;" does just that. It
# sent the database to binary heaven and it is now deleted.
Anyone who wishes to make additions or changes to this
MySQL Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999, 2000 by LinuxGuruz
Return to the LinuxGuruz MySQL Tutorials Page Return to the LinuxGuruz Main Page
|
Return to the LinuxGuruz MySQL Tutorials Page
Return to the LinuxGuruz Main Page
|
|