Click to See Complete Forum and Search --> : Sorting database
xstopx81
Aug 18th, 2000, 12:56 PM
in my database, i have the user put in people's name as a field. ex. "Micheal Johnson", i would like to sort all of the database using people's last name. I dont know how to do this with sql.
JHausmann
Aug 18th, 2000, 01:13 PM
Add a field to your table for storing Last name (or replace the single name field with 2 or 3 ).
xstopx81
Aug 18th, 2000, 01:41 PM
thanks for replying but that cannot be done because my program mostly based on full name...
JHausmann
Aug 18th, 2000, 02:32 PM
Yes it can be done, you just need to concatenate the fields together when you retrieve the data. Let's assume you've used Name as your current field.
Change the name of "Name" to "lastname" in your database.
If you add two more fields, "firstname" and "initial".
To retrieve all the following fields in one, use the following SQL:
select firstname + ' ' + initial + ' ' + lastname as name from table
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.