Question : MySQL join with Like

I am trying to find all the records from one table that match a term in another table.

I have tried

SELECT
FROM alerts LEFT OUTER JOIN ads ON alerts.searchterm LIKE '%', ads.DESCR ,'%'

I get an error saying that the sql is incorrect.

Answer : MySQL join with Like

you need to join the tables on a field from each with the same value (a id is usually the best, consider:

SELECT * FROM mydb.myTable1 LEFT JOIN mydb.myTable2 ON myTable1.myTableID1 = myTable2.myTableID2 WHERE myField LIKE '%string%';

or

SELECT myfield1,myfield2 FROM mydb.myTable1 LEFT JOIN mydb.myTable2 ON myTable1.myTableID1 = myTable2.myTableID2 WHERE myField LIKE '%string%';

or

SELECT myfield1,myfield2 FROM mydb.myTable1 LEFT JOIN mydb.myTable2 ON myTable1.myTableID1 = myTable2.myTableID2 WHERE myField LIKE '%string%';

hope this helps
Random Solutions  
 
programming4us programming4us