SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    opposite of LIKE "%foo%"

    Hi,

    SELECT * FROM table WHERE foo LIKE "%barbarbar%"
    will contain rows where foo contains "barbarbar"
    => for example where foo is "barbarbarbarbar"

    What I want, are the rows where "barbarbar" contains foo
    => for example where foo is "barbar"

    how to do it?

    Greetings, Andreas

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by godisatheist View Post
    What I want, are the rows where "barbarbar" contains foo
    => for example where foo is "barbar"
    would you please rephrase the question?

    which of those is the column? and which is the constant?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    foo is always the coloumn in this example.

    I think I found an possible solution:

    SELECT * FROM table WHERE "barbarbar" LIKE CONCAT('%' , foo , '%')

    Greetings, Andreas


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
  •