We could use an expression in the SELECT list:
SELECT t.id
, t.history
, t.active
, IFNULL(t.order,1) AS `order`
INTO @id
, @history
, @active
, @order
FROM `myTable` t
WHERE t.uid = ...
Note that DELIMITER is not a SQL statement; it's command recognized by the mysql command line client (and some other clients).
documented here in MySQL Reference Manual: https://dev.mysql.com/doc/refman/8.0/en/mysql-commands.html
It's not clear in what context this script is being run; is this part of a MySQL stored program, or being called application code. What we are actually trying to achieve?
There are several other expressions we could use in the SELECT list, e.g.
CASE WHEN t.order IS NULL THEN 1 ELSE t.order END`
or
IF(t.order IS NULL,1,t.order)
et al.
FOLLOWUP
If we don't want to modify the original SQL statement; if we execute this:
SELECT t.id
, t.history
, t.active
, t.jsonorder
INTO @id
, @history
, @active
, @jsonorder
FROM `myTable` t
WHERE t.uid = ...
And then we want to perform an assignment to another user defined variable, based on a conditional test, we can achieve that in another SELECT or a SET statement.
For example:
SELECT @myNewVal := IF(@jsonorder IS NULL,'zzz','yyy') ;
ELSE 'yyy'
-or-
SELECT CASE
WHEN @jsonorder IS NULL
THEN 'zzz'
ELSE 'yyy'
END
INTO @myNewVal
-or-
SET @myNewVal := IF(@jsonorder IS NULL,'zzz','yyy')
ORDERis a reserved word