কম্পিউটার

শর্তসাপেক্ষে MySQL-এ তারিখের মধ্যে/আগে/পরে কীভাবে নির্বাচন করবেন?


নিম্নলিখিত সিনট্যাক্স −

select *from yourTableName
where
yourColumnName1 < yourValue1 AND
(yourColumnName2 > yourValue2 OR yourColumnName2 is null);

আসুন একটি টেবিল তৈরি করি -

mysql> create table demo35
−> (
−> id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
−> joining_date date,
−> relieving_date date
−> );
Query OK, 0 rows affected (3.88 sec)

সন্নিবেশ কমান্ডের সাহায্যে টেবিলে কিছু রেকর্ড সন্নিবেশ করুন -

mysql> insert into demo35(joining_date,relieving_date) values('2020−01−10','2020−07−11');
Query OK, 1 row affected (0.15 sec)
mysql> insert into demo35(joining_date,relieving_date) values('2020−05−07','2020−12−08');
Query OK, 1 row affected (0.17 sec)
mysql> insert into demo35(joining_date,relieving_date) values('2020−04−11','2020−09−18');
Query OK, 1 row affected (0.14 sec)
mysql> insert into demo35(joining_date,relieving_date) values('2020−03−12','2020−10−01');
Query OK, 1 row affected (0.13 sec)

সিলেক্ট স্টেটমেন্ট -

ব্যবহার করে টেবিল থেকে রেকর্ড প্রদর্শন করুন
mysql> select *from demo35;

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
+----+--------------+----------------+
| id | joining_date | relieving_date |
+----+--------------+----------------+
|  1 | 2020−01−10   | 2020−07−11     |
|  2 | 2020−05−07   | 2020−12−08     |
|  3 | 2020−04−11   | 2020−09−18     |
|  4 | 2020−03−12   | 2020−10−01     |
+----+--------------+----------------+
4 rows in set (0.00 sec)

MySQL −

-এ শর্তসাপেক্ষে তারিখ নির্বাচন করার জন্য নিম্নোক্ত ক্যোয়ারী
mysql> select *from demo35
−> where
−> joining_date < '2020−05−11' AND
−> (relieving_date > '2020−08−10' OR relieving_date is null);

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
+----+--------------+----------------+
| id | joining_date | relieving_date |
+----+--------------+----------------+
|  2 | 2020−05−07   | 2020−12−08     |
|  3 | 2020−04−11   | 2020−09−18     |
|  4 | 2020−03−12   | 2020−10−01     |
+----+--------------+----------------+
3 rows in set (0.00 sec)

  1. মাইএসকিউএল সার্ভারের সাথে সংযোগ করার পরে আমরা কিভাবে কমান্ড প্রম্পট থেকে একটি ডাটাবেস নির্বাচন করতে পারি?

  2. MySQL SELECT স্টেটমেন্টে NULL কিভাবে ব্যবহার করবেন?

  3. মাইএসকিউএল-এ রিকারসিভ সিলেক্ট কোয়েরি কীভাবে করবেন?

  4. কিভাবে MySQL থেকে শেষ 10 সারি নির্বাচন করবেন?