How does MySQL database handle non-null value queries? MySQL non est nullum eligere dicitur

MySQL databaseQuomodo tractamus valorem non-nulli quaesitum?MySQL non est nullum eligere dicitur

Nulla tractatio in MySQL

Iam scimus MySQL uti imperio SQL SELECT et ubi clausula lege data in tabula data, sed cum condicione quaesitum est nullum ager provisum est, mandatum recte operari non potest.

Ad hanc condicionem tractandam, MySQL tres operatores maiores praebet:

  • NULLUS EST:Hic operator verum redit cum valor columnae NULLUS est.
  • NON EST NULLUS:Auctor redit verum cum valor columnae non est NULLUS.
  • <=>:  Auctor comparationis (dissimilis = operantis) verum redit cum duo valores comparati sunt NULL.

Operationes comparationis conditionalis in nullas speciales sunt.= NULL or uti non potes ! = NULL valores in columna invenit.

In MySQL, comparatio nullius pretii cum quovis alio valore (etiam NULL) falsa semper redit, id est NULL = NULL falsum redit.

NULLUS tractatur in MySQL utens NULLUS et operarius NULLUS NON.


Utere nullo valore in imperio promptum

In hoc exemplo, mensa chenweiliang_test_tbl in datorum chenweiliang posita est ut duas columnas contineat, chenweiliang_autoris et chenweiliang_count, et valores nullos in chenweiliang_count inserendi sunt.

Exempli gratia

Conare haec exempla:

Create data mensa chenweiliang_test_tbl

root @ host #mysql -u root -p password; 输入密码:*******
 mysql > 使用chenweiliang ;
数据库改变了mysql > create table chenweiliang_test_tbl 
 - > (
 - > chenweiliang_author varchar (40 )NOT NULL , - > chenweiliang_count INT 
 - > );
查询OK ,0 行受影响(0.05 秒)mysql >
 
 
INSERT INTO chenweiliang_test_tbl (chenweiliang_author ,chenweiliang_count )values (' chenweiliang ' ,20 );
mysql > INSERT INTO chenweiliang_test_tbl (chenweiliang_author ,chenweiliang_count )values (' 陈沩亮博客' ,NULL );
mysql > INSERT INTO chenweiliang_test_tbl (chenweiliang_author ,chenweiliang_count )values ( ' Google ' ,NULL );
mysql > INSERT INTO chenweiliang_test_tbl (chenweiliang_author ,chenweiliang_count )values (' FK ' ,20 );
 
mysql > SELECT * from chenweiliang_test_tbl ; + --------------- + -------------- + | chenweiliang_author | chenweiliang_count | + --------------- + -------------- + | chenweiliang | 20 | | 陈沩亮博客| NULL | | Google | NULL | | FK | 20 | + --------------- + -------------- +
 4 行中集合(0.01 秒) 

In exemplo videre potes = et ! Auctor = non operatur;

mysql > SELECT * FROM chenweiliang_test_tbl WHERE chenweiliang_count = NULL ;
空集(0.00 秒)mysql > SELECT * FROM chenweiliang_test_tbl WHERE chenweiliang_count != NULL ;
空集(0.01 秒)

Ut scias num columna chenweiliang_test_tbl in tabula data nulla sit, uti debetIS NULLautemIS NOT NULLtale exemplum;

mysql > SELECT * FROM chenweiliang_test_tbl WHERE chenweiliang_count IS NULL ; + --------------- + -------------- + | chenweiliang_author | chenweiliang_count | + --------------- + -------------- + | 陈沩亮博客| NULL | | Google | NULL | + --------------- + -------------- +
 2 行中的组(0.01 秒)的MySQL > SELECT * 从chenweiliang_test_tbl WHERE chenweiliang_count IS NOT 空值 
 
 ; + --------------- + -------------- + | chenweiliang_author | chenweiliang_count | + --------------- + -------------- + | chenweiliang | 20 | | FK | 20 | + --------------- + -------------- +
 2 行中的组(0.01 秒) 

Nullas valores cum scripto PHP contrectando

In PHP scriptione, uti potes, si... alia enuntiatione ad processum num variabilis inanis est et congruentem enuntiationem conditionalem generare.

In hoc exemplo PHP variabilis $chenweiliang_count ponit et deinde utitur qui variabilis ad comparandum cum agro chenweiliang_count in tabula data:

ORDINE MySQL test:

<?
php $ dbhost = ' localhost:3306 ' ; // mysql服务器主机地址

$ dbuser = ' root ' ; // mysql用户名
$ dbpass = ' 123456 ' ; // mysql用户名密码
$ conn = mysqli_connect ($ dbhost ,$ dbuser ,$ dbpass );
如果(!$ conn ){ die (' 连接失败:' 。mysqli_error ($ conn ));
} // 设置编码,防止中文乱码

mysqli_query ($ conn ,“ set names utf8 ” );
 
if (isset ($ chenweiliang_count )){ $ sql = “ SELECT chenweiliang_author,chenweiliang_count FROM chenweiliang_test_tbl WHER chenweiliang_count = $ chenweiliang_count ” ;
} else { $ sql = “ SELECT chenweiliang_author,chenweiliang_count FROM chenweiliang_test_tbl WHER chenweiliang_count IS NULL ” ;
} mysqli_select_db ($ conn ,'


 chenweiliang ' );
$ retval = mysqli_query ($ conn ,$ sql );
if (!$ retval ){ die (' 无法读取数据:' 。mysqli_error ($ conn ));
} echo ' <h2>陈沩亮博客IS NULL测试<h2> ' ;
echo ' <table border =“1”> <tr> <td>作者</ td> <td>登陆次数</ td> </ tr> ' ;

 $ retval ,MYSQL_ASSOC )){ echo “ <tr> ” 。
 “ <td> {$ row ['chenweiliang_author']} </ td> ” 。
 “ <td> {$ row ['chenweiliang_count']} </ td> ” 。
 “ </ tr> ” ;
} echo ' </ table> ' ;
mysqli_close ($ conn );
?>

 

Spes Chen Weiliang Blog ( https://www.chenweiliang.com/ ) participatur "Quomodo facit MySQL database manubrium non-nullum valorem queries? MySQL sententia selecta non est nulla "ad auxilium te".

Grata communicare nexum huius articuli:https://www.chenweiliang.com/cwl-491.html

Grata ad canalem Telegram Chen Weiliang's blog ut tardus updates!

🔔 Primus esto ut magni pretii "ChatGPT Content Marketing AI tool Usage Guide" in canali summo presul! 🌟
📚 Hic dux ingens valorem continet, 🌟 Haec rara occasio est, id non fallunt! ⏰⌛💨
Share and like si libet!
Tua communicatio et similia continua sunt motiva nostra!

 

发表 评论

Tua inscriptio electronica Quisque sit amet nisl. 必填 项 已 用 * Pittacium

volumen ad top