Search code examples
mysqlsqljoinsql-like

MySQL LEFT JOIN and ON w/ LIKE - this query will not run but the match does exist


Does my query follow correct format? I can't find any examples of using LIKE and ON, so I am not sure if my query is the problem. Looking for any suggestions or feedback:

SELECT * 
FROM table_1 a
LEFT JOIN table_sql ON a.case_id LIKE '%45305%'

Solution

  • This is not correct, you need to specify which column you want to use for the JOIN, but you can do something like this

    SELECT * from table_1 AS a
       LEFT JOIN table_sql AS b
       ON a.case_id = b.id
    WHERE
       a.case_id LIKE '%45305%'