SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Hibernator YuriKolovsky's Avatar
    Join Date
    Nov 2007
    Location
    Malaga, Spain
    Posts
    1,072
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    select * where value contains field

    in mysql , how can you select the rows where 'some value' contains field


    where field contains value works fine, but i need the reverse, along the lines of select * from table where 'somevalue' contains field, is it possible in mysql?


    clarifying example

    | version | ref |
    | version1 | 1.1 |
    | version2 | 1.1.1 |

    select * from table where '1.1.1' contains ref

    how to do the above?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by YuriKolovsky View Post
    clarifying example
    sorry, example did not clarify

    is this what you mean?
    Code:
    WHERE '1.1.1' LIKE CONCAT('%',ref,'%')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please try to explain your problem better because I don't get it.

    From what I understand you simply want:
    WHERE ref='ref'
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  4. #4
    Hibernator YuriKolovsky's Avatar
    Join Date
    Nov 2007
    Location
    Malaga, Spain
    Posts
    1,072
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    sorry, example did not clarify

    is this what you mean?
    Code:
    WHERE '1.1.1' LIKE CONCAT('%',ref,'%')


    i think i do

    yes, it works perfectly, thanks!!

  5. #5
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    WHERE '1.1.1' LIKE CONCAT('%',ref,'%')
    Great concept !!
    I am noting this.


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
  •