MySQL LIKE Statement not working! Please help!

Discussion in 'MySQL' started by LiftBigEatBig, Jun 18, 2011.

  1. #1
    I'm trying to copy data from one table to another.

    UPDATE tblMerchants T,retailers R 
    SET T.linklabel=R.linklabel,T.logo_image=R.logo_image,T.screen_image=R.screen_image,T.category=R.category,T.meta_description=R.meta_description,T.meta_title=R.meta_title,T.meta_keywords=R.meta_keywords,T.intro=R.intro,T.permalink=R.permalink,T.excerpt=R.excerpt,T.main_link=R.main_link,T.related_blog_post=R.related_blog_post,T.active=R.active,T.homepage_fea
    tured=R.homepage_featured 
    WHERE T.homepageurl LIKE '%R.linklabel%'
    Code (markup):
    T.homepageurl would like http://www.amazon.com/ and R.linklabel would look like amazon.com. So I can't figure out why its not working. I'm not getting any errors, its just saying 0 rows affected.

    Any help is greatly appreciated! Thanks!
     
    Last edited: Jun 18, 2011
    LiftBigEatBig, Jun 18, 2011 IP
  2. LiftBigEatBig

    LiftBigEatBig Well-Known Member

    Messages:
    302
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    123
    #2
    I just tried doing an INSERT SELECT statement:

    INSERT INTO tblMerchants (linklabel,logo_image,screen_image,category,meta_description,meta_title,meta_keywords,intro,permalink,excerpt,main_link,related_blog_post,active,homepage_featured) SELECT linklabel,logo_image,screen_image,category,meta_description,meta_title,meta_keywords,intro,permalink,excerpt,main_link,related_blog_post,active,homepage_featured FROM retailers WHERE tblMerchants.homepageurl LIKE "%retailers.linklabel%"
    Code (markup):
    Now I'm getting a different error:#1054 - Unknown column 'tblMerchants.homepageurl' in 'where clause'

    Doesn't make sense since I know homepageurl is a column in the tblMerchants table....
     
    LiftBigEatBig, Jun 18, 2011 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    LIKE should contain a value not a column name.
     
    mwasif, Jun 18, 2011 IP