SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: ENDS WITH

Hybrid View

  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    ENDS WITH

    I have a query where I want to search for fields that ends with no.jpg
    I have a table where some have file/no.jpg and some fields where it's only no.jpg

    Now I would like to look for all that ends with no.jpg to find the fields where an image isn't added yet.

    This almost what it looks like now, but I need help with how to write it correct.

    PHP Code:
    SELECT FROM table_img WHERE table_img.pic 'file/no.jpg' 

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,096
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    Is there any reason you have different values for "no image". If not I would update to just one image and then just query for that.

    Otherwise,

    Code SQL:
    SELECT something, anything, just_not_the_dreaded_star FROM table_img WHERE table_img.pic = 'no.jpg' OR table_img.pic = 'file/no.jpg'
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    Grüße aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Just out of interest, would it be possible/make sense to use a reg exp?

    Code SQL:
    SELECT the_dreaded_star FROM table_img WHERE table_img.pic REGEX 'no.jpg$'

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,223
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Just out of interest, would it be possible/make sense to use a reg exp?

    Code SQL:
    SELECT the_dreaded_star FROM table_img WHERE table_img.pic REGEX 'no.jpg$'
    I was thinking along the same lines, that or using RIGHT(table_img.pic, 5) = 'no.jpg'

  5. #5
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    646
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I discovered that there weren't that many different ones, so I went in to the table and changed the the old ones to the new name instead. So, now I only need to look for one of them.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •