Hi,
I'm trying to create a SP to filter out a selection of vehicles that come in a certain colour. I've been filtering out with make model year...... but when i came to colour i didn't want to repeat that info. This is the small snip of sql for the colour.
use master
go
--drop database dbcolourtest;
go
create database dbcolourtest;
go
use dbcolourtest;
go
create table tbVehicle
(VehicleID int primary key identity (0,1),
vehtype Varchar (50),
vehYear Varchar (4),
vehMake Varchar (50),
vehModel Varchar (50),
vehPrice SMALLMONEY,
vehCondition Varchar (50))
insert into tbVehicle (vehType, vehYear, vehMake, vehModel, vehPrice,vehCondition) values
('SUV', '2013','KIA','SORENTO', 25350.00, 'NEW'),
('CAR', '2013', 'PORCHE', 'PANAMERO', 175300.00,'NEW'),
('CAR', '2012','VW','BEETLE',23395.00,'USED'),
('TRUCK','2011','GM','CANYON',24750.00,'USED'),
('TRUCK','2010', 'FORD','F-150',31161.00,'USED'),
('SUV','2009','FORD','EXPLORER',25985.00,'USED'),
('CAR','2013','FORD','MUSTANG',43066.00,'NEW'),
('CAR','2013','BMW','Three SERIES',89523.00,'NEW')
select Distinct vehPrice
from tbVehicle
order by vehPrice asc
create table tbColour
(ColourID int primary key identity (0,1),
colColour varchar (50))
insert into tbColour (colColour) values
('Red'),
('Green'),
('Silver'),
('Black'),
('Purple'),
('Blue'),
('White'),
('Brown'),
('Sport Black'),
('Brugandy'),
('Orange'),
('Light Blue')
select * from tbColour
create table tbColourSelection
(ColourSelectionID int primary key identity(0,1),
ColourID int,
VehicleID int)
insert into tbColourSelection (VehicleID, ColourID) values
(0,3),(0,7),(0,6),
(1,5),(1,0),(1,6),
(2,11),(2,0),(2,8),(2,6),
(3,5),(3,10),(3,0),
(4,5),(4,0),(4,6),
(5,3),(5,5),(5,9),
(6,5),(6,1),(6,4),(6,6),
(7,5),(7,0),(7,2)
select * from tbColourSelection
Below is where I'm having the big problem.....or maybe someone has a different approach. Im using this database in a VS form too. Thanks so much
select vehtype, vehMake, vehModel, colColour, vehPrice
from tbVehicle, tbColour, tbColourSelection
where tbVehicle.VehicleID = tbcolour.VehicleID and
tbColour.ColourID= tbColour.ColourID and
ColourID = 'Sport Black'
'Stop my insanity'