Is it possible to reference back to the column you’re selecting in the WHERE condition?
I’m not even sure how to ask this question without excessive verbage, so I’ll just try to point you to the “rated_user = @2User” part and note that @2User is what I’m selecting.
SELECT id, user, minimum
INTO @1ID, @1User, @minimum
FROM table1
WHERE a_or_b = 'a' AND item = itemName
ORDER BY number DESC LIMIT 1;
SELECT id, user
INTO @2ID, @2User
FROM table1
WHERE a_or_b = 'b' AND item = itemName
AND (SELECT IFNULL(AVG(rating),0) AS Rating
FROM table2
WHERE rated_user = @2User AND completed = 'y'
) >= @minimum_seller_rating
ORDER BY number ASC LIMIT 1;
You should be able to just use the original column name from the parent table in the sub query as well.
If there is a name collision, you may need to prefix it with the table name or alias.