dbTalk Databases Forums  

Query Help.

comp.databases.ms-access comp.databases.ms-access


Discuss Query Help. in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kissi Asiedu
 
Posts: n/a

Default Query Help. - 02-10-2011 , 09:03 PM






I need to delete the last character in a field. Can somone help with a query
or SQL statement please?

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Query Help. - 02-10-2011 , 09:40 PM






Kissi Asiedu wrote:
Quote:
I need to delete the last character in a field. Can somone help with a
query or SQL statement please?
Let's say you had a table called Emps and a field called LastName, 1
record, and had a value of Smith. You could create a column called
Minus1Char to return Smit to see how that works.

In the query builder enter
Minus1Char : Left([LastName],Len(LastName)-1)

Len returns the length of a string. Subtract 1 from that value. Now
get the n number of chars starting from the beginning of the string to
the length value using the function Left()

To update the value of the field LastName in table Emps you'd use an
update query.
UPDATE Emps SET LastName = Left([LastName],Len([LastName])-1);

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.