Find Shoe Size Selection
So it seems like you're missing the where clause which would filter out the undesirable results. In this example I'm assuming 2 is a decent threshold and using a between clause to limit the output. Greater than with a limit would also work but it really depends on the dataset. 

SELECT
    size_name,
    length,
    ABS(length - ' . $input-&gt;length . ') AS length_difference,
    width,
    ABS(width - ' . $input-&gt;width . ') AS width_difference
FROM
    SIZES
WHERE 
    length BETWEEN $input-&gt;length AND ($input-&gt;length + 2)
    AND width BETWEEN $input-&gt;width AND ($input-&gt;width + 2)

ORDER BY
    length_difference
LIMIT 2


Here's the example using greater than.

SELECT
    size_name,
    length,
    ABS(length - ' . $input-&gt;length . ') AS length_difference,
    width,
    ABS(width - ' . $input-&gt;width . ') AS width_difference
FROM
    SIZES
WHERE 
    length &gt; $input-&gt;length
    AND width &gt; $input-&gt;width

ORDER BY
    length_difference
LIMIT 2