Re: Stuck on creating an easy view, please help
From: Anith Sen (anith_at_bizdatasolutions.com)
Date: 09/08/04
- Next message: JT Lovell: "Re: Question on scope of temp tables created via SP"
- Previous message: JoelB: "Triggers, performance, and distributed processing"
- In reply to: yessica_s: "Stuck on creating an easy view, please help"
- Next in thread: Thanks: "Re: Stuck on creating an easy view, please help"
- Reply: Thanks: "Re: Stuck on creating an easy view, please help"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 8 Sep 2004 15:23:07 -0500
>> Or do you know of a better way to get the result I want?
Yup. First, you have to reconsider your design. Since multiple values are
concatenated to form a string for the team, your design suffers from severe
logical problems inherent to multi-valued systems. A reasonable approach,
based on your narrative would be to have the tables like:
CREATE TABLE Requests (
Request_id INT NOT NULL,
Team_id INT NOT NULL
REFERENCES Teams ( Team_id )
PRIMARY KEY ( Request_id, Team )
);
CREATE TABLE Teams (
Team_id INT NOT NULL PRIMARY KEY ,
Descr VARCHAR(10) NOT NULL
) ;
You can have your data like:
INSERT Requests SELECT 240, 2 ;
INSERT Requests SELECT 240, 3 ;
INSERT Requests SELECT 241, 1 ;
INSERT Requests SELECT 242, 1 ;
INSERT Requests SELECT 242, 2 ;
INSERT Requests SELECT 242, 3 ;
INSERT Teams SELECT 1, 'SC' ;
INSERT Teams SELECT 2, 'PE' ;
INSERT Teams SELECT 3, 'CO' ;
Most query expressions using SQL would be trivial with such a schema & what
you are requesting is no different. However, if you are looking for a
concatenated string as your output, I would recommend you extract the
resultset & do the concatenation leveraging the client programming
language's string manipulation functions.
-- Anith
- Next message: JT Lovell: "Re: Question on scope of temp tables created via SP"
- Previous message: JoelB: "Triggers, performance, and distributed processing"
- In reply to: yessica_s: "Stuck on creating an easy view, please help"
- Next in thread: Thanks: "Re: Stuck on creating an easy view, please help"
- Reply: Thanks: "Re: Stuck on creating an easy view, please help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|