Click here to Skip to main content
15,895,084 members
Home / Discussions / Database
   

Database

 
GeneralRe: create forenkey syntex Pin
vipinpaliwal198025-May-06 17:54
vipinpaliwal198025-May-06 17:54 
QuestionDbf Tables & Sql Strings Pin
Vinicius Pontes23-May-06 10:11
Vinicius Pontes23-May-06 10:11 
AnswerRe: Dbf Tables & Sql Strings Pin
Eric Dahlvang24-May-06 3:06
Eric Dahlvang24-May-06 3:06 
Question-- Is it possible??? -- Pin
WetRivrRat23-May-06 9:56
WetRivrRat23-May-06 9:56 
AnswerRe: -- Is it possible??? -- Pin
Eric Dahlvang24-May-06 3:36
Eric Dahlvang24-May-06 3:36 
GeneralRe: -- Is it possible??? -- Pin
WetRivrRat24-May-06 4:01
WetRivrRat24-May-06 4:01 
AnswerRe: -- Is it possible??? -- Pin
Eric Dahlvang24-May-06 8:35
Eric Dahlvang24-May-06 8:35 
AnswerRe: -- Is it possible??? -- [modified] Pin
Michael Potter24-May-06 3:41
Michael Potter24-May-06 3:41 
Alias your phone table and join to employees twice. Use a left join so you are sure to get every employee even if they don't have the certain type of phone number.

SELECT
    Name,
    empID,
    a.phone_num as phone_num1,
    b.phone_num as phone_num2,
    activeUser,
    contact
FROM
    employees
LEFT JOIN
    phone a
    ON (employees.empID = a.EmpID AND
        a.type = 1)
LEFT JOIN
    phone b
    ON (employees.empID = b.EmpID AND
        b.type = 2)


You can also use a correlated sub query. This method won't be as fast as the first method.

SELECT
    Name,
    empID,
    (SELECT TOP phone_num 
     FROM Phone
     WHERE empId = employees.empId AND
           type = 1) as phone_num1,
    (SELECT TOP phone_num 
     FROM Phone
     WHERE empId = employees.empId AND
           type = 2) as phone_num2,
    activeUser,
    contact
FROM
    employees



-- modified at 14:52 Thursday 25th May, 2006
GeneralRe: -- Is it possible??? -- Pin
WetRivrRat24-May-06 4:16
WetRivrRat24-May-06 4:16 
GeneralRe: -- Is it possible??? -- Pin
Eric Dahlvang24-May-06 9:31
Eric Dahlvang24-May-06 9:31 
QuestionPls Help MS Access Pin
achrafus23-May-06 8:46
achrafus23-May-06 8:46 
QuestionSQL Express to Access Pin
Kschuler23-May-06 8:29
Kschuler23-May-06 8:29 
AnswerRe: SQL Express to Access Pin
Eric Dahlvang23-May-06 9:29
Eric Dahlvang23-May-06 9:29 
QuestionBest way to get Today in DateTime Pin
Rob Philpott23-May-06 7:07
Rob Philpott23-May-06 7:07 
AnswerRe: Best way to get Today in DateTime Pin
Eric Dahlvang23-May-06 8:00
Eric Dahlvang23-May-06 8:00 
GeneralRe: Best way to get Today in DateTime Pin
Rob Philpott23-May-06 8:07
Rob Philpott23-May-06 8:07 
GeneralRe: Best way to get Today in DateTime Pin
Eric Dahlvang23-May-06 8:29
Eric Dahlvang23-May-06 8:29 
QuestionInserting Image in my Report (ReportViewer) Pin
anderslundsgard23-May-06 4:28
anderslundsgard23-May-06 4:28 
QuestionProgrammatically Updating a Table with Detail from derived from another Table Pin
AnneThorne23-May-06 3:45
AnneThorne23-May-06 3:45 
QuestionData base connection problem Pin
iz723-May-06 2:28
iz723-May-06 2:28 
QuestionSQL Server does not exist or access denied [modified] Pin
sarah_chandran23-May-06 0:57
sarah_chandran23-May-06 0:57 
AnswerRe: SQL Server does not exist or access denied [modified] Pin
sathish s23-May-06 2:11
sathish s23-May-06 2:11 
GeneralRe: SQL Server does not exist or access denied [modified] Pin
sarah_chandran23-May-06 3:14
sarah_chandran23-May-06 3:14 
Questionwriting query using comma separator Pin
dayakar_dn23-May-06 0:09
dayakar_dn23-May-06 0:09 
AnswerRe: writing query using comma separator [modified] Pin
Frank Kerrigan23-May-06 0:46
Frank Kerrigan23-May-06 0:46 

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.