$sql = "SELECT COUNT(*) FROM theTable A INNER JOIN theTable B ON (A.column_1 = $value_x and B.column_1 = $value_y AND A.column_2 = B.column_2)";