0
-- phpMyAdmin SQL Dump
-- version 3.2.4
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jun 22, 2011 at 08:44 AM
-- Server version: 5.1.41
-- PHP Version: 5.3.1

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `test1`
--

-- --------------------------------------------------------

--
-- Table structure for table `data`
--

CREATE TABLE IF NOT EXISTS `data` (
  `test` int(10) NOT NULL,
  `test1` int(10) NOT NULL,
  `test2` int(10) NOT NULL,
  `total` int(20) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

--
-- Dumping data for table `data`
--

INSERT INTO `data` (`test`, `test1`, `test2`, `total`) VALUES
(20, 20, 20, 0);

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by smantscheff
0

Hi all above is my table there is four rows, three rows have value like :test=20, test1=20, test2=20. now my prob. is this can i calculate this three row value in total row like (total=60). this should be auto.....is it possible plz help me ....thanks in advance.

0

while inserting you can do like

INSERT INTO `data` (`test`, `test1`, `test2`, `total`) VALUES(20, 20, 20, 20+20+20);

after inserting you must run update query like

update data set total=test+test1+test2 where total=0
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.