Reputation: 31
I have 2 columns abc and bcd i want to compare abc data with bcd column exact match and sentence contain abc.
Expected Result
Upvotes: 0
Views: 227
Reputation: 95101
Are you trying to select all rows where there exists a row the abc of which matches the rows' bcd? Then use EXISTS
.
select *
from mytable
where exists
(
select null
from mytable other
where mytable.bcd like concat('%', other.abc, '%')
)
order by abc, bcd;
Upvotes: 1
Reputation: 2253
You can achieve it like this:
SELECT * FROM table_name WHERE table_name.abc like CONCAT('%', table_name.bcd, '%');
This will return all records where string from abc
column is contained in a string from bcd
column.
Of course, replace table_name
with your table name.
Upvotes: 0