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
SQL Query to Join Two Tables Based Off Closest Timestamp
How to Create Xml Schema from an Existing Database in SQL Server 2008
Differencebetween Join Keyword and Inner Join Keyword in Oracle SQL
What Determines the Locking Order for a Multi-Table Query
SQL Server Group by Query Select First Row Each Group
Rounding to 2 Decimal Places in SQL
SQL Server 'In' or 'Or' - Which Is Fastest
How to Create a Postgres Table with Unique Combined Primary Key
Set Empty Strings ('') to Null in the Whole Database
Postgres SQL 'Could Not Determine Data Type of Parameter' by Hibernate
How to Execute a Stored Procedure Over a Set Without Using a Cursor
Convert Rows to Columns Using 'Pivot' in Mssql When Columns Are String Data Type
SQL Question: Does the Order of the Where Clause Make a Difference
Create Unqiue Case-Insensitive Constraint on Two Varchar Fields
Sql: Retrieve Only the Records Whose Value Has Changed