Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pull Multiple Phone Records On Contact Row
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01463756
Message ID:
01463816
Vues:
47
Hi Kev,

Something's not right. Here's my queries
SELECT RecordId, FirstName, LastName FROM Contacts WHERE LastName = 'marois'
RecordId    FirstName   LastName
-------------------------------------------------------
4010        Kevin      Marois



SELECT * FROM Phones WHERE ContactId = 4010
RecordId    ContactId   PhoneTypeId PhoneNum
----------- ----------- ----------- --------------------------------------------------
58920       4010        4           +19513920229
58921       4010        1           +19512233208

SELECT * FROM PickLists WHERE ItemType = 'phone'
RecordId    Caption                        ItemType
----------- ------------------------------ --------------------
1           Home                           phone
2           Office                         phone
3           FAX                            phone
4           Cell                           phone
5           Other1                         phone
6           Other2                         phone
7           Other3                         phone

SELECT ContactId, [1] AS [Home], [2] AS Office, [3] AS Fax, [4] AS Cell, [5] AS [Other1], [6] AS [Other2], [7] AS [Other3]
	FROM Phones
    PIVOT (MIN(PhoneNum) FOR PhoneTypeID IN ([1], [2], [3], [4], [5], [6], [7])) TempList
	WHERE ContactId = 4010

ContactId   Home            Office     Fax		  Cell            Other1     Other2     Other3
----------- --------------- ---------- ---------- --------------- ---------- ---------- ----------
4010        NULL            NULL       NULL       +19513620229    NULL       NULL       NULL
4010        +19512433208    NULL       NULL       NULL            NULL       NULL       NULL
Notice that I'm getting back 2 rows. Never used Pivot tables before, so I'm not entirely sure what's wrong.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform