-- 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 */;

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.

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

Thanks,
Thanks Dear for solve my prob.

If this is a recurring task, you should use triggers or (with MariaSQL) virtual columns.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.