Answer the question
In order to leave comments, you need to log in
MySQL JOIN expression?
Good afternoon. The following working SQL statement is currently being used:
SELECT T.*, I.SUBDIR, I.FILE_NAME, ep.VALUE AS AV
FROM (SELECT p.ID, p.ACTIVE, p.NAME, p.CODE, p.DETAIL_PICTURE, p.PREVIEW_TEXT, p.PREVIEW_PICTURE, p.DETAIL_TEXT, p.IBLOCK_SECTION_ID, e.PRICE
FROM b_iblock_element p, b_catalog_price e WHERE e.PRODUCT_ID = p.ID AND p.IBLOCK_ID = 2 and p.ACTIVE = "Y" and e.CATALOG_GROUP_ID = 1) T
LEFT JOIN b_file I ON T.DETAIL_PICTURE = I.ID
LEFT JOIN b_iblock_element_property ep ON ep.IBLOCK_ELEMENT_ID = T.ID AND ep.IBLOCK_PROPERTY_ID = 2242 WHERE 1';
Answer the question
In order to leave comments, you need to log in
I managed to solve the problem by adding the following parameter to the first line of SELECT:
And at the very end, removing WHERE 1, add JOIN:
Thanks who helped!
Dock or, if in Russian - www.cyberforum.ru/mysql/thread782307.html
WHERE 1 this is visible from the cms piece.
"where 1" is equal to "where true", which means always true, this is probably necessary to compose the next filtering parameters. For example, we have a code that filters according to the following principle:
if ( condition) then add "and expression from the condition" to the where block. Without where 1 there will be a syntax error.
On the main question, if you need to add two values, then perhaps like this
"and e.CATALOG_GROUP_ID in (1,2)" or like this "and (e.CATALOG_GROUP_ID=1 or e.CATALOG_GROUP_ID=2)"
Where the syntax is most clearly explained ? in reference of course!
www.mysql.ru/docs/man/JOIN.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question