Tema: Re: kita mysql uzklausa :)
Autorius: kantas
Data: 2009-05-01 19:50:19
nereikalignas reply'jus, apsizioplinau:)
dekui Jornada :)

On Fri, 01 May 2009 08:08:25 +0000, kantas wrote:

> jeigu kas nors nepatingetu pazhaisti...
> 
> CREATE TABLE IF NOT EXISTS `t1` (
>   `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT
>   NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
> 
> INSERT INTO `t1` (`id`, `name`) VALUES (1, 'vardas1'),
> (2, 'vardas2');
> 
> 
> CREATE TABLE IF NOT EXISTS `t2` (
>   `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `t1_id` int(11) NOT
>   NULL,
>   `kaina` decimal(10,2) DEFAULT NULL,
>   PRIMARY KEY (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
> 
> 
> INSERT INTO `t2` (`id`, `t1_id`, `kaina`) VALUES (1, 1, '30.00'),
> (2, 1, '20.00');
> 
> tai va, rezultate niekaip nepavyksta gauti pagal si pavyzdi, kad:
> vardas1 sum(kaina) = 50, o vardas2 sum(kaina) = 0