It's not important to the current problem, but the "where '1'='1'" is so that i can re-use the query by passing in a where clase such as
Code: Select all
Database jbat running on localhost
# phpMyAdmin SQL Dump
# version 2.5.5-pl1
# http://www.phpmyadmin.net
#
# Host: localhost
# Generation Time: Aug 21, 2004 at 10:36 AM
# Server version: 4.0.18
# PHP Version: 5.0.0RC2
#
# Database : `jbat`
#
# --------------------------------------------------------
#
# Table structure for table `customer`
#
CREATE TABLE `customer` (
`customer_id` int(11) NOT NULL auto_increment,
`first_name` varchar(32) NOT NULL default '',
`middle_name` varchar(32) NOT NULL default '',
`last_name` varchar(32) NOT NULL default '',
`address_number` varchar(8) NOT NULL default '',
`address_street` varchar(32) NOT NULL default '',
`address_suburb` varchar(32) NOT NULL default '',
`address_state` char(3) NOT NULL default '',
`address_postcode` varchar(4) NOT NULL default '',
`date_of_birth` varchar(10) NOT NULL default '',
`sex` enum('Male','Female') NOT NULL default 'Male',
`email` varchar(64) NOT NULL default '',
`fax_number` varchar(16) NOT NULL default '',
`home_phone_number` varchar(16) NOT NULL default '',
`work_phone_number` varchar(16) NOT NULL default '',
`mobile_number` varchar(16) NOT NULL default '',
`notes` text NOT NULL,
PRIMARY KEY (`customer_id`)
) TYPE=MyISAM AUTO_INCREMENT=8 ;
#
# Dumping data for table `customer`
#
INSERT INTO `customer` VALUES (1, 'JohnA', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (2, 'JohnB', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (3, 'JohnC', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (4, 'JohnD', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (5, 'JohnE', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (6, 'JohnF', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
INSERT INTO `customer` VALUES (7, 'JohnG', 'M.', 'Doe', '22', 'Some St.', 'Kingsford', 'NSW', '1234', '1980-01-06', 'Male', 'none@none.com', '', '99996666', '', '0404040404', 'cazy dude');
# --------------------------------------------------------
#
# Table structure for table `invoice`
#
CREATE TABLE `invoice` (
`invoice_id` int(11) NOT NULL auto_increment,
`customer_id` int(11) NOT NULL default '0',
`cost` decimal(10,2) NOT NULL default '0.00',
`discount_reason` text NOT NULL,
PRIMARY KEY (`invoice_id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
#
# Dumping data for table `invoice`
#
INSERT INTO `invoice` VALUES (1, 1, '61.00', '');
INSERT INTO `invoice` VALUES (2, 2, '60.00', '');
INSERT INTO `invoice` VALUES (3, 3, '60.00', '');
INSERT INTO `invoice` VALUES (4, 1, '50.00', '');
# --------------------------------------------------------
#
# Table structure for table `payment`
#
CREATE TABLE `payment` (
`payment_id` int(11) NOT NULL auto_increment,
`invoice_id` int(11) NOT NULL default '0',
`payment_type` enum('Cash','Cheque','Credit') NOT NULL default 'Cash',
`cost` decimal(10,2) NOT NULL default '0.00',
`date` varchar(10) NOT NULL default '',
PRIMARY KEY (`payment_id`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;
#
# Dumping data for table `payment`
#
INSERT INTO `payment` VALUES (1, 1, 'Cash', '61.00', '2004-04-04');
INSERT INTO `payment` VALUES (2, 2, 'Cash', '20.00', '2004-04-06');
INSERT INTO `payment` VALUES (3, 2, 'Cash', '20.00', '2004-04-06');