Does Mysql: if judge whether it is better to write at the business layer or at the database layer?

if in the business layer, within a transaction, there is an if judgment
read in the database first, judge according to the result if else, and then read / write to the database

and there are if else statements within the mysql database

if you are in the business tier, you need to send two sql requests
to the database and put them inside the database, then you only need to send the sql statement once

.

which is better?

Mar.02,2021

is not good.
see if there is too much data in your database.
if there is a lot of data and performance is required, then a sql solves the problem.
but it is usually written in the business layer.

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-1bf4361-54b3a.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-1bf4361-54b3a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?