Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

sql statement mysql joint to table and sum

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;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial