Hi all,
I have a table with transfer prices between 2 destinations. The structure of the table is described below. What I need, is a query that will return the following from 'location_prices_1_2008':
'Balule Nature Reserve', 'Balule Nature Reserve', 0.00
'Balule Nature Reserve', 'Berg-en-dal Camp (K.N.P.)', 1650.00
'Balule Nature Reserve', 'Blue Mountain Lodge', 1430.00
'Balule Nature Reserve', 'Buhala Country Lodge', 1650.00
'Balule Nature Reserve', 'Bongani Mountain Reserve', 1540.00
Instead of:
0, 0, 0.00
0, 1, 1650.00
0, 2, 1430.00
0, 3, 1650.00
0, 4, 1540.00
I just don't know how to do a multiple join ( location_from and location_to ) on 1 table (locations)...
Here's the scripts to create the table structure and insert some sample data.
--
-- Create the location_prices_1_2008 table:
--
CREATE TABLE location_prices_1_2008 (
Location_From int(11) NOT NULL default '0',
Location_To int(11) NOT NULL default '0',
Price decimal(19,2) NOT NULL default '0.00'
);
--
-- Dumping data for table 'location_prices_1_2008'
--
INSERT INTO location_prices_1_2008 (Location_From, Location_To, Price) VALUES (0, 0, 0.00);
INSERT INTO location_prices_1_2008 (Location_From, Location_To, Price) VALUES (0, 1, 1650.00);
INSERT INTO location_prices_1_2008 (Location_From, Location_To, Price) VALUES (0, 2, 1430.00);
INSERT INTO location_prices_1_2008 (Location_From, Location_To, Price) VALUES (0, 3, 1650.00);
INSERT INTO location_prices_1_2008 (Location_From, Location_To, Price) VALUES (0, 4, 1540.00);
--
-- Create the locations table:
--
CREATE TABLE locations (
Location_ID int NOT NULL default '0',
Location_Name varchar(255) NOT NULL default ''
)
--
-- Dumping data for table 'locations'
--
INSERT INTO locations VALUES (0, 'Balule Nature Reserve');
INSERT INTO locations VALUES (1, 'Berg-en-dal Camp (K.N.P.)');
INSERT INTO locations VALUES (2, 'Blue Mountain Lodge');
INSERT INTO locations VALUES (3, 'Buhala Country Lodge');
INSERT INTO locations VALUES (4, 'Bongani Mountain Reserve');
Start Free Trial