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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to edit a field

Status
Not open for further replies.

deecee

Technical User
Aug 25, 2001
1,678
US
I have a field that has image location

folder/folder/image.jpg

is how it is set up -- I have over 150 images in this dbase so i dont want to do what i have to do individually.

what i want to do is remove folder/folder/

so all i have is "image.jpg" no quotes of course

How do i remove folder/folder/?

If there is a sql command what is it?

Thanks

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
update tablename
set fieldname=string(&quot;newfolder/newfolder/&quot;,substr(fieldname,len(fieldname)-10),len(fieldname))


something like this but i am a bit drunk right not so i am not sure ;)

10 is the length from image.jpg, it could also be 9 or so. don';t know if the length is the same all tne time
 
hehe will ill give it a shot tomorrow and let you know -- thanks -- besides in about 3 hours ill catch up to you

://

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
the directory names are most likely going to change, yes? i would advise doing it some other way, possibly changing the string outside of mysql with whatever scripting language you are using with it (php?).
 
you can also remove the whole dir string from the field. and work with variables inside php where you define the path to your images
 
i just want to have the filenames by themselves -- i use php to add the filenames to the directories -- usually used as a repeated region so i only need enter it once

so i can say &quot;folder/images.image.jpg&quot; or change it to &quot;images/download/image.jpg&quot; and all i need to have in my dbase is image.jpg



<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
so have all the filenames got the same size in filename??

in that case you can use
update tablename
set fieldname=substr(fieldname,len(fieldname)-10),len(fieldname))


 
thats the thing they dont have the same filenamelength its sku#.jpg and skus can range from AN100 to 393-55-987black.jpg

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
can i do this from the left -- rather than count right to left can i go left to right and say this is what i want deleted?

<Signature>
Sometimes the Answer You Are LOOKING for can be FOUND BY SEARCHING THE FAQ'S @&%$*#!!!
</Signature>
 
yep you use the substr function for that,

as show above but then otherway around
set fieldname=substr(fieldname,12,len(fieldname))

will return the fieldname starting at position 11

(try first which number you have to fill in by using this in plain sql)

select substr(fieldname,12,len(fieldname)) from table


 
if u use php then u can use strrpos function. i am giving below a sample quote

Code:
<?
    $nm=&quot;dir1/dir2/omg.jpg&quot;;
    $pos=strrpos($nm, '/') ;
    $newstr=substr($nm, $pos +1 ) ;
    print (&quot;position is = $pos and string is $newstr\n&quot;) ;

?>

strrpos returns the last matching char so u can elimante the / from varibale lenght string



[ponder]
----------------
ur feedback is a very welcome desire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top