इसके लिए ORDER BY ISNULL() का उपयोग करें। पहले एक टेबल बनाते हैं:
mysql> create table DemoTable669 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentScore int ); Query OK, 0 rows affected (0.55 sec)
इन्सर्ट कमांड का उपयोग करके टेबल में कुछ रिकॉर्ड डालें:
mysql> insert into DemoTable669(StudentScore) values(45) ; Query OK, 1 row affected (0.80 sec) mysql> insert into DemoTable669(StudentScore) values(null); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable669(StudentScore) values(89); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable669(StudentScore) values(null); Query OK, 1 row affected (0.15 sec)
सेलेक्ट स्टेटमेंट का उपयोग करके टेबल से सभी रिकॉर्ड प्रदर्शित करें:
mysql> select *from DemoTable669;
यह निम्न आउटपुट देगा:
+-----------+--------------+ | StudentId | StudentScore | +-----------+--------------+ | 1 | 45 | | 2 | NULL | | 3 | 89 | | 4 | NULL | +-----------+--------------+ 4 rows in set (0.00 sec)
गैर-खाली मानों को आरोही क्रम में प्रदर्शित करने की क्वेरी। NULL मान बाद में प्रदर्शित होंगे:
mysql> select *from DemoTable669 ORDER BY ISNULL(StudentScore),StudentScore;
यह निम्न आउटपुट देगा:
+-----------+--------------+ | StudentId | StudentScore | +-----------+--------------+ | 1 | 45 | | 3 | 89 | | 2 | NULL | | 4 | NULL | +-----------+--------------+ 4 rows in set (0.00 sec)