how to fetch Mysql data by like %column name%

Problem :

the concept is for matching user relation and fetch post from timeline table

Table: Timeline {id,title,privacyTimeline} Table: friend_request{id,requestType,status,from_id,to_id}

i am trying to fetch where privacy and requestType match but there is value in separated by comma privacyTimeline = 'family,friends' requestType ='family'

i have wrote this query but not work with like'%%'

FROM timeline t JOIN
     friend_request fr
WHERE (fr.from_id = '3' OR fr.to_id='3') AND
      (t.privacyTimeline LIKE '%f.requestType%')

does not work

but its work when i replace column name fr.requestType to siple text 'family' SELECT,t.title FROM timeline as t JOIN friend_request as fr WHERE(fr.from_id = '3' OR fr.to_id='3') AND(t.privacyTimeline LIKE '%family%')

please anyone who can guide me

Solution :

Use string concatenation:

t.privacyTimeline LIKE CONCAT('%', f.requestType, '%')

Mysql Tutorials

Mysql Howto..

How to change the collation to make mysql case insensitive

How to select the first post using mySQL

MySQL how to avoid duplicate row

How to insert 2 post (submitted) values that begins with specific names to same table row, and loop for more same results?

“Show databases” with condition

Show the best player depend of Medals achieved Mysql/php

How to do a sum of previous rows in mysql a sum of previous rows [duplicate]

How to mass edit and replace MySQL database row, replacing all using a list?

How to create an insert Form with TextInput containing ComboBox provided by mySQL Database Table

How to use MySQL group_concat() function in more than one column

MySQL How can I make a better query to connect two tables through my bridge table?

How to load mysql database from data folder?

How to make MySQL run more efficiently?

How to best handle exception to repeating calendar events

How to make a dropdown stay when processing different If/Else blocks?

How to close PHP loop that inserts from DOM into MySQL

How do I add foreign key constraints in my innodb table without indexing the columns?

How can I store data from mySQL database into an array?

MySQL : How to get records are have non null values?

how to change timestamp format in mysql

How to use an sql subquery that uses count

How to convert a date and time to be stored in mysql datetime

How to manage database and queries of a multi-tagged/multi-categorized article/post

How to communicate with MySQL from java [duplicate]

How do I resolve “incompatible library version” for mysql2 gem with ruby 2.3 on OS X?

How to set $variable as a DATE_FORMAT in MySQL

MySQL - How can I use left join to get exactly one row from a joined table in the on clause?

How to handle too long index names in a Rails migration with MySQL?

How can I manipulate MySQL fulltext search relevance to make one field more 'valuable' than another?

How to change order of substrings inside a larger string?