remove some data (1 Viewer)

kitty77

Registered User.
Local time
Today, 15:25
Joined
May 27, 2019
Messages
712
I changed a field from a hyperlink to a text field. Some of the data now looks like this...

www.abc.com#blahhhh

How can I get rid of (in a query) everything to the right of #? Including the # too.

Thanks!
 

Cronk

Registered User.
Local time
Tomorrow, 05:25
Joined
Jul 4, 2013
Messages
2,772
Use an update query

Code:
update yourTableName set yourFieldName = left(yourFieldName, instr(yourFieldName, "#") -1)
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 20:25
Joined
Sep 12, 2006
Messages
15,652
Something like this. someone probably has a much slicker pattern matching approach.
You may need to allow for not finding the # character in the search string.

Code:
if instr(yourtext,"#")>0 then
   yourtext = left(instr(yourtext,"#")-1)
end if

you could even split your string on the "#" character and take the first elelment

not sure of the precise format, but this sort of thing.
Code:
split(yourtext,"#")(0)
 

kitty77

Registered User.
Local time
Today, 15:25
Joined
May 27, 2019
Messages
712
Use an update query

Code:
update yourTableName set yourFieldName = left(yourFieldName, instr(yourFieldName, "#") -1)
Some of my data does not have the "#", so how can I make the value = the field value if no "#"?
 

Cronk

Registered User.
Local time
Tomorrow, 05:25
Joined
Jul 4, 2013
Messages
2,772
Or add a where statement to the SQL

Try
Code:
update yourTableName set yourFieldName = left(yourFieldName, instr(yourFieldName, "#") -1) where instr(yourFieldName, "#") >0
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 03:25
Joined
May 7, 2009
Messages
19,230
or simply:
update yourTableName set yourFieldName = left(yourFieldName, instr(yourFieldName, "#") -1) where yourFieldName Like "*[#]*";
 

Users who are viewing this thread

Top Bottom