Click to See Complete Forum and Search --> : How to eleiminate the first character
Sheryll018
October 12th, 2005, 05:06 AM
hi everyone...can i ask how to eliminate the first character in a field in SQL?
for example i have GSUPERUSER in my field named usergroup and i wanted to eliminate the letter 'G' so that the result would be 'SUPERUSER' only.
Thanks very much.
srinika
October 12th, 2005, 10:41 AM
If u want to view data;
Select right(Usergroup, len(RTrim(Usergroup))-1) from MyTable
or if u want to change data
Update MyTable set Usergroup = right(Usergroup, len(RTrim(Usergroup))-1)
Sheryll018
October 12th, 2005, 11:02 PM
Thanks SRINIKA!
Select right(Usergroup, len(RTrim(Usergroup))-1) from MyTable
this really help me but i have noticed that the column name had gone...thats why i cannot perform the INNER JOIN because the column name becomes ambiguous as it contains "(No Column Name)" instead of "USERGROUP"
What seems to be the problem? Pls. enlighten me.
Thanks.
srinika
October 13th, 2005, 07:53 AM
U can use alias (as follows);
Select right(Usergroup, len(RTrim(Usergroup))-1) as [UserGroup] from MyTable
or something as
Select right(Usergroup, len(RTrim(Usergroup))-1) as [UG] from MyTable
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.