DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

SQL Query For Contacts

  • submit to reddit
        // SQL query for contacts

// insert code here..
SELECT tblContacts.ContactID, [LastName] & ", " & [FirstName] AS ContactName, tblContacts.FirstName,
 tblContacts.LastName, tblContacts.Salutation, tblContacts.StreetAddress, tblContacts.City,
 tblContacts.StateOrProvince, tblContacts.PostalCode, tblContacts.Country, tblContacts.CompanyName,
 tblContacts.JobTitle, tblContacts.Use
FROM tblContacts
ORDER BY [LastName] & ", " & [FirstName];



Snippets Manager replied on Thu, 2009/11/05 - 9:14am

Can also be written like this: SELECT c.ContactID, (c.LastName + ", " + c.FirstName) AS ContactName, c.FirstName, c.LastName, c.Salutation, c.StreetAddress, c.City, c.StateOrProvince, c.PostalCode, c.Country, c.CompanyName, c.JobTitle, c.Use FROM tblContacts as c ORDER BY c.LastName, c.FirstName;