I want to know if there is a way to use a user-defined variable in WHERE clause, as in this example:
WHERE
SELECT id, location, @id := 10 FROM songs W
Sure, but I've never seen anyone try to set a variable and use it in the same statement like you are. Try:
SET @id := 10; SELECT @id := 10 FROM songs WHERE id = @id;
or
SELECT @id := 10 FROM songs; SELECT @id := 10 FROM songs WHERE id = @id;
I've used both, and they both seem to work for me.