Click here to Skip to main content
15,914,419 members
Home / Discussions / Database
   

Database

 
GeneralRe: Comparing two tables in SQL Pin
r.stropek4-Jun-06 6:02
r.stropek4-Jun-06 6:02 
Questionretreiving a perticular column in a table Pin
dayakar_dn16-May-06 20:13
dayakar_dn16-May-06 20:13 
AnswerRe: retreiving a perticular column in a table Pin
Colin Angus Mackay16-May-06 21:47
Colin Angus Mackay16-May-06 21:47 
QuestionHow to download/copy a data stored as image type in SQL Pin
SIJUTHOMASP16-May-06 18:51
professionalSIJUTHOMASP16-May-06 18:51 
QuestionWhich of all DBMS? Pin
Lord_Vader16-May-06 10:30
Lord_Vader16-May-06 10:30 
AnswerRe: Which of all DBMS? Pin
Al Ortega16-May-06 10:38
Al Ortega16-May-06 10:38 
AnswerRe: Which of all DBMS? Pin
Colin Angus Mackay16-May-06 21:58
Colin Angus Mackay16-May-06 21:58 
Questionreplacing idnums with values... Pin
Jesse Evans16-May-06 8:14
Jesse Evans16-May-06 8:14 
Hi, folks!

I hope I can explain this properly...

I have two tables. One is a list of people's first and last names and there is an Identity column to uniquely select the proper row.

The other table is a list of email forwards; in other words I want to keep track of how a particular email is passed about with the group. This table has a column that uniquely id's the message, a column for the id of the forwarder and a column for the id of the forwardee. The id's come from the usernames table. So far, so good.
<br />
TABLE [Employees] (<br />
	[idnum] [int] IDENTITY (1, 1) NOT NULL ,<br />
	[firstname] [varchar] (50) NOT NULL ,<br />
	[lastname] [varchar] (50) NOT NULL ,<br />
)<br />
<br />
TABLE [tblDownLogForwards] (<br />
	[idnum] [int] IDENTITY (1, 1) NOT NULL ,<br />
	[TicketNumber] [int] NOT NULL ,<br />
	[IdForwardFrom] [int] NOT NULL ,<br />
	[IdForwardTo] [int] NOT NULL ,<br />
	[ForwardDate] [datetime] NOT NULL <br />
)<br />


Now, I want to report these forwards, but of course I want to make it easy to interpret so instead of the id's I want to include the user's first and last names, something like this:
<br />
msgNum - ForwarderFirstName - ForwarderLastName - ForwardeeFirstName - ForwardeeLastName<br />

How do I specify an SQL statement to replace the user id's with their names? I thought the following might do the trick, but it only selects records having the same id as forwarder and forwardee:
<br />
select ticketnumber, forwarddate, Employees.lastname as FromLast, Employees.firstname as FromFirst, Employees.lastname as ToLast, Employees.firstname as ToFirst from tblDownlogforwards inner join Employees on Employees.idnum = tblDownlogforwards.IdForwardFrom and Employees.idnum = tblDownlogforwards.IdForwardTo<br />


If I elliminate the last equality, I get records where the ForwardTo columns have the same person's name, even when another id is present.

I'm very perplexed by this...

Thanks!

'til next we type...
HAVE FUN!! -- Jesse

-- modified at 14:17 Tuesday 16th May, 2006
AnswerRe: replacing idnums with values... Pin
Eric Dahlvang16-May-06 11:44
Eric Dahlvang16-May-06 11:44 
GeneralRe: replacing idnums with values... Pin
Jesse Evans16-May-06 11:58
Jesse Evans16-May-06 11:58 
QuestionHow will catch a error in DA Class From Stored Procedures Pin
NICE TO MEET16-May-06 2:31
NICE TO MEET16-May-06 2:31 
AnswerRe: How will catch a error in DA Class From Stored Procedures Pin
Not Active16-May-06 2:51
mentorNot Active16-May-06 2:51 
GeneralRe: How will catch a error in DA Class From Stored Procedures Pin
Paddy Boyd16-May-06 3:06
Paddy Boyd16-May-06 3:06 
GeneralRe: How will catch a error in DA Class From Stored Procedures Pin
Rob Graham16-May-06 4:34
Rob Graham16-May-06 4:34 
Questionreturn values from stored procedure Pin
DineshSharma16-May-06 2:25
DineshSharma16-May-06 2:25 
AnswerRe: return values from stored procedure Pin
Paul Brower16-May-06 5:33
Paul Brower16-May-06 5:33 
QuestionHow to access Query Designer in Microsoft SQL Server Management Studio? Pin
FionaDM16-May-06 1:32
FionaDM16-May-06 1:32 
AnswerRe: How to access Query Designer in Microsoft SQL Server Management Studio? Pin
Kevin McFarlane16-May-06 11:08
Kevin McFarlane16-May-06 11:08 
QuestionWrite Sub Query in mySQL Pin
Harrison.Brock15-May-06 17:57
Harrison.Brock15-May-06 17:57 
AnswerRe: Write Sub Query in mySQL Pin
Paddy Boyd16-May-06 2:49
Paddy Boyd16-May-06 2:49 
GeneralRe: Write Sub Query in mySQL Pin
Harrison.Brock16-May-06 6:39
Harrison.Brock16-May-06 6:39 
GeneralRe: Write Sub Query in mySQL Pin
Harrison.Brock16-May-06 7:41
Harrison.Brock16-May-06 7:41 
Questioncan you help me comparate the date Pin
Mohammed Amine15-May-06 13:32
Mohammed Amine15-May-06 13:32 
AnswerRe: can you help me comparate the date Pin
Shaikat6915-May-06 19:58
Shaikat6915-May-06 19:58 
Questionchange server name Pin
Paps215-May-06 9:00
Paps215-May-06 9:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.