Angel_AD
(Andrewdemial)
1
Hello everyone)) I very ned your help.
I have two tables: documents and countries with relationship as many to many. And I need realize the next SQL query:
SELECT * FROM documents INNER JOIN document_country ON document_country.id_document = documents.id WHERE document_country.id_country = 1 AND 2;
On the Yii2 I write the following code:
$query = andFilterWhere([‘and’, ‘id_document=1’, 2]);
And I have only a row when id_document = 1;
What do I wrong? How I can win this AND?
softark
(Softark)
2
What do you want?
WHERE document_country.id_country = 1 AND document_country.id_country = 2
or
WHERE document_country.id_country = 1 OR document_country.id_country = 2
?
hrnair
(Harikrishnan Hr)
3
SELECT * FROM documents INNER JOIN document_country ON document_country.id_document = documents.id WHERE document_country.id_country = 1 AND 2;
will give the same result if you use any number more than zero instead of the last 2 - it will be taken as TRUE.
That’s what I think. You may check your query again.