এজন্য 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)
কিছু রেকর্ড ইনসার্ট করি (NULL সহ):
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)