i have 2 table sale , and payment how can i joint to table when iI sale customer sometime paymeny time for some item so i should have table payment to record it how can i write sql statement like merk statement
sale.preselRef sale.name sale.grandtotal sum from table payment group by saleid (match with sale.preselRef )
-- Table structure for table `sale`--CREATE TABLE IF NOT EXISTS `sale` ( `preselRef` int(12) NOT NULL, `nameid` int(11) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, ----- `grandtotal` decimal(10,2) DEFAULT NULL,CREATE TABLE IF NOT EXISTS `payment` ( `id` int(11) NOT NULL, `saleid` int(11) NOT NULL, `type` varchar(80) COLLATE utf8_bin NOT NULL, `amount` decimal(11,2) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;