MySQL: Null variable

This entry is part 20 of 26 in the series Learn MySQL

If the statement returns no rows, no assignment takes place, and the variable retains its previous value.

If the variable has not been used previously, that value is NULL:

select @price := price from artist where price > 10;
select @price


Series Navigation<< MySQL: Saving the last inserted id using LAST_INSERT_ID()
MySQL: Setting a variable to a value >>

Leave a comment

Leave a Reply