Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about This Query and Sorting.... Is It Possible?

Status
Not open for further replies.

stephenmbell

IS-IT--Management
Jan 7, 2004
109
US
I am in the middle of building a small web based contacts application. Prior to this, my client was using Yahoo for their contacts - but certain security issues have come up.

My question is this..

my contacts table looks somewhat like this..
----------
id
firstname
middle
lastname
homephone
workphone
mobile
fax
other
address
companytitle
jobtitle
companyaddress
notes
----------

And here is where I am stuck... I am using an Access DB for a backend. I want to query the contacts and order them by Lastname, Firstname **BUT - if there is a company name, I want to order by that

example:

Adams, Mike
Andrews, Dave
Apple Store
Bell, Dan
Best Western

is this possible with having all of the data in the same table??

Thanks.
 
access sql is different from ansi sql, perhaps on your next post you could try the access forum :)

but in the meantime, you can try this --
Code:
select iif(isnull(companytitle)
        or len(rtrim(companytitle))=0
          , lastname & ', ' & firstname
          , companytitle) as sortvalue
  from contacts
order by sortvalue

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top