MySQL query to fetch data that matches data in another table

Viewed 23

So we have two tables:

Tabl№1

| Ads | Date  |
| :--------- | :-------------- |
| Buy Auto    | dd.MMMM.yyyy         |
| Wanted equipment    | dd.MMMM.yyyy         |
| Work    | dd.MMMM.yyyy         |
| Buy water    | dd.MMMM.yyyy         |

Tabl№2

| Zag |
| :--------- |
| auto    |
| equipment    |

How to write a query to MySQL table Tabl№1 to get only the data that matches the condition:

  1. To take only those rows from the 'Ads' column of Tabl№1 that match the data from the 'Zag' column from TablNo2

As a result, it should receive only such data from Tabl№1:

| Ads | Date  |
| :--------- | :-------------- |
| Buy Auto    | dd.MMMM.yyyy         |
| Wanted equipment    | dd.MMMM.yyyy         |

I do this but it doesn't work :((((

SET lc_time_names = 'ru_RU';
SELECT *
FROM `Tabl№1`
WHERE (`Date` REGEXP '^[0-9]+:[0-9]+$'
OR LOWER(`Date`) LIKE "%сегодня%")
AND `Ads` LIKE (SELECT st.`Zag` FROM `Tabl№2` as st)
0 Answers
Related