Use a Like Clause in Part of an Inner Join

Use a LIKE clause in part of an INNER JOIN

Your first query will work but will require a full table scan because any index on that column will be ignored. You will also have to do some dynamic SQL to generate all your LIKE clauses.

Try a full text search if your using SQL Server or check out one of the Lucene implementations. Joel talked about his success with it recently.

Like operator in inner join in SQL

A bit of an odd data model aside, you've turned the tables around in the LIKE part (table1.name should be a part of table2.name, not the other way around), and you need to add the percents to the value, not the name of the field, that means not quoting the name;

SELECT table1.*, table2.z
FROM table1
INNER JOIN table2
ON table2.name LIKE CONCAT('%', table1.name, '%')
AND table1.year = table2.year

An SQLfiddle to test with.

Like operator in SQL Inner Join

I think you are compare # too... try to replace it:

Select 
t1.Handle ,
t1.Name ,
t1.Description
from
table1 t1 inner join table2 t2
on t2.Handle = t1.Handle
inner join table3 t3
on t2.Handle like CONCAT('%',REPLACE( t3.CurrentHandle,'#',''), '%')

Hope this help!

Big query inner join with 'like' clause

switch lower(a.quarters) and b.land_url for the LIKE check

Select a.quarters as Quarters, sum(b.clicks) as Clicks
from `spreadsheetapi-1147.FlosportsDatabase.GroupByColumnReference` as a
inner join `spreadsheetapi-1147.FlosportsDatabase.kenshoo` as b
on b.land_url like concat('%' , lower(a.quarters) , '%' )
group by a.quarters

Inner join with like operator?

MS-Access uses * where you have %

https://support.office.com/en-gb/article/like-operator-b2f7ef03-9085-4ffb-9829-eef18358e931

(One of many reasons I hate MS-Access, it's too proprietary)

Inner join with like clause

you have to form the clause using concat ...

...LIKE CONCAT('%',tbl_albums.name, '%');

there is no + operator like this in mysql



Related Topics



Leave a reply



Submit