peri hokiperihokiclarustologisticsrimashaop.compola taktis menang gates of olympus x1000 perihokipemain perihoki bongkar trik jepep starlight princess x1000perihoki beri panduan lengkap bermain mahjong ways 2 pgsofttips cara penghasil uang pgsoft mahjong ways 2 perihokimahjong wins 3 perihoki memberikan penggali terbesarfenomena gates of olympus buka peluang besar bagi duta76cara dapat pola emas rahasia di duta7 wild west goldtrik menang pgsoft mahjong ways 2 modal receh maxwin duta76duta76 main pgsoft mahjong ways 2 di sela istirahatscatter hitam mahjong wins 3 spin pasti jepe duta76perihoki spin mahjong ways 2 pgsoft scatter hitam maxwinsimbol mahjong wins 3 yang sering muncul di awal perihokitrik gampang menang mahjong winscuan mahjong wins 3 tanpa hentipola spin taruhan kecil mahjong winsstrategi kunci scatter hitam beruntungacor total mahjong wayskemenangan maksimal mahjong wayskemenangan pria pekanbaru mahjong waysmahjong wins3 fenomena baru sumatera baratmenangkan mahjong dengan lincahmenembus batas keberuntungan mahjong waysmenjajal keberuntungan di mahjong wayspola gratis mahjong ways1scatter hitam senjata rahasia mahjong winsteknik spinning menguntungkan untuk scatter hitamanalisis rtp tertinggi mahjong winsfenomena scatter hitam mahjong winsibu rumah tangga dan keberuntungan mahjongkeseruan main mahjong wins3menang mahjong pengguna baru di sosial mediamenghargai setiap momen di mahjong waysserunya main mahjong di warung internetspin slow motion mancing scatterstrategi jitu maxwin mahjong waysstrategi jitu menang mahjong modal kecil jackpot besaranak kampung papua menggemparkan mahjongkeajaiban scatter hitam mahjong wayskeberhasilan joni mahjong winskejaiban mahjong ways di ujung jalanketua mahjong wins3 kehadiran kemenangan dimulai dari balimahjong kehadiran yang menguntungkanmahjong menggila adat88panduan kilat raih 108 jutatips memenangkan mahjongbarista kopi menang 110 juta spin mahjongdakota76 scatter hitam mahjong wins 3gagal cpns menang mahjong wins 3 rp120 jutakisah karyawan minimarket dapat thr lebih awal mahjong winskisah pelajar sma kuasai mahjong wins 3 inspirasi sekolahkisah penjaga parkir tanah abang motor baru mahjong winskisah sukses ibu rumah tangga bandung mahjong winsmahasiswa kkn beli iphone15 mahjong wins3 dakotamantan anak band influencer mahjong scatter hitampola rtp senin gates of olympus guru matematikaidola scatter hitam gampang meledakidola sensasi jackpotidola pola scatter hitamidola hasilkan jackpot dalam waktu singkatidola mahjong wins 3 bocortukang cuci motor menemukan keberuntungan di mahjong

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 282

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_set_cookie_params(): Cannot change session cookie parameters when headers already sent

Filename: Session/Session.php

Line Number: 294

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 304

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 314

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 315

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 316

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 317

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: Session/Session.php

Line Number: 375

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time

Filename: drivers/Session_files_driver.php

Line Number: 108

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_set_save_handler(): Cannot change save handler when headers already sent

Filename: Session/Session.php

Line Number: 110

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Cannot start session when headers already sent

Filename: Session/Session.php

Line Number: 143

Backtrace:

File: /home/blogchuabenh/domains/freetuts.net/public_html/site/controllers/Main_controller.php
Line: 10
Function: __construct

File: /home/blogchuabenh/domains/freetuts.net/public_html/sources/index.php
Line: 299
Function: require_once

File: /home/blogchuabenh/domains/freetuts.net/public_html/index.php
Line: 26
Function: require_once

Toán tử BETWEEN và NOT BETWEEN trong SQL - Freetuts
TABLE QUERIES
DATA QUERIES
CONDITION & OPERATOR
ADVANCED
CÁC CHỦ ĐỀ
BÀI MỚI NHẤT
MỚI CẬP NHẬT

Toán tử BETWEEN và NOT BETWEEN trong SQL

Toán tử BETWEEN dùng để kiểm tra một giá trị có nằm trong một khoảng giá trị hay không, nó có thể được sử dụng với kiểu number, date, text. Đối với number và text thì sẽ sắp xếp dựa vào thứ tự của bảng mã ASCII.

test php

banquyen png
Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức.

1. Cú pháp toán tử BETWEEN

Bạn hãy xem cú pháp sau:

SELECT column_name_list
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

Trong đó:

  • column_name là cột bạn muốn kiểm tra
  • value1value2 là giới hạn giá trị, tức là cận trên và cận dưới.

Ví dụ 1: Lấy danh sách sinh viên có tuổi trong khoảng từ 20 đến 25.

Bài viết này được đăng tại [free tuts .net]

SELECT *
FROM STUDENTS
WHERE AGE BETWEEN 20 AND 25

Ví dụ 2: Lấy danh sách đơn hàng đăng ký từ ngày 20/11/2017 đến ngày 22/12/2017

SELECT *
FROM ORDERS
WHERE ADD_DATE BETWEEN "20/11/2017" AND "22/12/2017"

2. Toán tử NOT BETWEEN

Với toán tử BETWEEN là kiểm tra tồn tại trong khoảng thì NOT BETWEEN sẽ kiểm tra giá trị không nằm trong khoảng, tức là nó phủ định.

Cú pháp như sau:

SELECT column_name_list
FROM table_name
WHERE column_name NOT BETWEEN value1 AND value2;

Ví dụ: Lấy tất cả khách hàng trừ những khách hàng có tuổi không nằm trong khoảng 20 đến 30

SELECT *
FROM CUSTOMERS
WHERE AGE NOT BETWEEN 20 AND 30

3. Toán tử thay thế

Trường hợp bài toán bắt buộc tìm trong khoảng thì bạn cũng có thể sử dụng toán tử AND thay thế cho BETWEEN và OR thay thế cho NOT BETWEEN. Như các ví dụ ở trên thì mình sẽ viết lại như sau:

AND thay thế BETWEEN
SELECT *
FROM STUDENTS
WHERE AGE >= 20 AND AGE <= 25

OR thay thế NOT BEtWEEN
SELECT *
FROM CUSTOMERS
WHERE AGE < 20 OR AGE > 30

Trên là cách sử dụng toán tử so sánh trong khoảng, nó rất hữu ích và giúp ta xây dựng câu SQL trông sạch hơn.

Cùng chuyên mục:

Phiên làm việc là gì trong SQL

Phiên làm việc là gì trong SQL

Trong bài viết này mình sẽ giải thích phiên làm việc là gì trong SQL…

Ràng buộc Check trong SQL

Ràng buộc Check trong SQL

Bài này bạn sẽ được học cách tạo ràng buộc giá trị trong SQL bằng…

Khóa ngoại Foreign Key trong SQL

Khóa ngoại Foreign Key trong SQL

Trong bài này bạn sẽ được học cách tạo khóa ngoại Foreign Key bằng câu…

Primary Key trong SQL

Primary Key trong SQL

Bài này bạn sẽ được giới thiệu cách tạo khóa chính (Primary Key) thể hiện…

Create và Drop Database trong SQL

Create và Drop Database trong SQL

Bài viết này sẽ hướng dẫn bạn cách sử dụng lệnh Create Database để tạo…

Subquery trong SQL - truy vấn con

Subquery trong SQL - truy vấn con

Trong bài này mình sẽ nói đến một cách sử dụng câu truy vấn SLECT…

Self Join trong SQL

Self Join trong SQL

Mỗi phép Join đều phải có hai bảng table1 và table2, tuy nhiên có trường…

Right Join trong SQL

Right Join trong SQL

Chào các bạn, hôm nay mình sẽ tiếp tục nói đến phép Join trong SQL.…

Left Join trong SQL

Left Join trong SQL

Ở bài trước chúng ta đã được tìm hiểu Inner Join và biết được tại…

Inner JOIN trong SQL

Inner JOIN trong SQL

Ở bài trước chúng ta đã học hiểu cách truy vấn nhiều bảng trong SQL…

Tìm hiểu ALIAS  (AS) trong SQL

Tìm hiểu ALIAS (AS) trong SQL

Trong bài này mình sẽ nói về cách đặt lại tên cho column, table bằng…

Tích đề các trong SQL

Tích đề các trong SQL

Trong bài này mình sẽ hướng dẫn các bạn cách truy vấn dữ liệu trên…

Gộp dữ liệu với UNION và UNION ALL trong SQL

Gộp dữ liệu với UNION và UNION ALL trong SQL

Có một số trường hợp bắt buộc bạn phải chạy hai câu truy vấn nên…

Lọc dữ liệu trùng với DISTINCT trong SQL

Lọc dữ liệu trùng với DISTINCT trong SQL

Đôi khi có những câu truy vấn có kết quả bị trùng lặp thì lúc…

Toán tử AND và OR trong SQL

Toán tử AND và OR trong SQL

Trong bài này chúng ta học hai toán tử có thể nói là được sử…

Toán tử IN và NOT IN trong SQL

Toán tử IN và NOT IN trong SQL

Trong bài này chúng ta sẽ học hai lệnh mới dùng để kiểm tra một…

Toán tử LIKE và NOT LIKE trong SQL

Toán tử LIKE và NOT LIKE trong SQL

Trong bài này chúng ta sẽ tìm hiểu lệnh LIKE, lệnh này dùng để so…

Sắp xếp dữ liệu với ORDER BY trong SQL

Sắp xếp dữ liệu với ORDER BY trong SQL

Nếu bạn muốn sắp xếp dữ liệu trả về theo tăng dần hoặc giảm dần…

Lệnh Delete trong SQL

Lệnh Delete trong SQL

DELETE FROM posts WHERE post_id > 7000 AND post_content IS NOT NULL;

Lệnh Update trong SQL

Lệnh Update trong SQL

Trong bài này chúng ta sẽ tìm hiểu đến lệnh UPDATE, đây là lệnh dùng…

Top