insert into foo_table (fname, lname, number)
values ('John', 'Doe', if(123 = 456));
For the above MySQL query, can somebody kindly explain what the if(123 = 456) is doing? I currently struggle to see an if statement without a body (i.e. if(condition){ // do something });
('John', 'Doe', 0). As for the reason to have this, you will need to ask the person who wrote it.IF()function requires 3 arguments. The first argument is a condition expression. If it's true the function returns the second argument, otherwise it returns the third argument.