The MySQL query is :
     SELECT 
     p1.id,p1.name, p1.category_id, p1.price AS p1_price, p2.price as p2_price 
     FROM
     products p1 
     LEFT JOIN products p2 
     ON p1.category_id=p2.category_id AND  
     p1.price<p2.price AND p2.price IS NULL
The products table  is shown in the following screenshot :
And the result the query produces is in the following screenshot :
The result actually shows the table as it is with just a column (i.e. p2_price) with all NULL values.
But the condition AND p2.price IS NULL in the ON condition seems to be never true as no row
in the table p2 has NULL value in the price column. So how is the result produced ?
EDIT: this question never uses the term INNER JOIN and is therefore not any duplicate of any question regarding INNER JOIN.
EDIT2: This question is about MySQL, so it cannot be termed as duplicate of any question of other language i,e. SQL .


 
     
     
     
    