Mysql implements if judgment statements without using stored procedures

< H1 > achieve the goal: < / H1 >

determines whether the field exists, and if so, does not change it.
if the field does not exist, execute the new field source the default value is null , and the existing field source is set to 0

< H2 > the existing code is as follows < / H2 >
IF NOT EXITS (SELECT * FROM information_schema.columns where table_schema = DATABASE()  AND table_name = "file" AND column_name = "source") THEN
    Alter table file add source varchar(20);
    Update file set source = "0";
END IF;
Mar.23,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b34a-4eedc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b34a-4eedc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?