In one table there are two fields (pole1 and pole2) you need to compare these two fields with another table that has (pole). Tell me how to execute the query sql?
3 answers
This question has already been asked Comparison of two MySQL tables . Some information about JOIN's https://anton-pribora.ru/articles/mysql/mysql-join/
|
Somewhere like this:
SELECT * FROM TableOne t1 LEFT JOIN TableTwo t2 on t1.id = t2.id WHERE t1.pole1 = t2.pole AND t1.pole2 = t2.pole; - Your option does not work, that's how I originally had SELECT * FROM base WHERE man = '". $ People."' ' - keaks88
- I need another man2 to compare with $ people - keaks88
- @ keaks88, describe the structure of the base - Yaroslav
- man and man2 are in the table they have id and people are in another table, when comparing, if all 3 have the same id then we output a specific record - keaks88
- @ keaks88, as I understand it, man and man2 are in the same table and they have the same id? - Yaroslav
|
if knit on pole
SELECT t1.pole1, t1.pole2, t2.pole,t3.pole FROM TableOne t1 LEFT JOIN TableTwo t2 on t1.pole1 = t2.pole LEFT JOIN TableTwo t3 on t1.pole2 = t3.pole |