Lệnh IN Trong SQL - Deft Blog
Có thể bạn quan tâm
Mục lục
- 1 Câu điều kiện IN
- 2 Thể phủ định NOT IN
Điều kiện IN được dùng trong SQL để giảm thiểu việc phải sử dụng quá nhiều điều kiện OR trong các lệnh SELECT, INSERT, UPDATE hoặc DELETE. Cho phép chúng ta liệt kê một tập hợp các giá trị có thể có của một biểu thức cụ thể.
Câu điều kiện IN
Cú pháp
biểu thức IN (giá trị 1, giá trị 2, … giá trị n);biểu thức
Giá trị để kiểm tra
giá trị 1, giá trị 2, … giá trị n
Các giá trị để kiểm tra với biểu thức
Lưu ý
- Điều kiện IN trong SQL sẽ trả về các bản ghi khi biểu thức có giá trị là giá trị 1, giá trị 2, … hoặc giá trị n.
- Điều kiện IN trong SQL còn được gọi là toán tử IN.
Ví dụ tìm tất cả các nhanvien có họ thuộc Smith, Anderson hay Johnson
SELECT * FROM nhanvien WHERE ho IN (‘Smith’, ‘Anderson’, ‘Johnson’); SELECT * FROM nhanvien WHERE ho = ‘Smith’ OR ho = ‘Anderson’ OR ho = ‘Johnson’;Thể phủ định NOT IN
Trái ngược lại với IN, NOT IN dùng để chỉ ra một tập dữ liệu mà các biểu thức không được chứa.
SELECT * FROM nhanvien WHERE ten NOT IN (‘Sarah’, ‘John’, ‘Dale’);Câu truy vấn trên sẽ trả về tập kết quả các nhân viên có họ khác với Sarah, John hay Dale.
Prev Article Next Article 5 3 votes Article Rating Subscribe Login Notify of new follow-up comments new replies to my comments

Bài viết liên quan
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Read More
In case of sale of your personal information, you may opt out by using the link Do Not Sell My Personal Information
Accept Decline Cookie Settings I consent to the use of following cookies: Necessary Marketing Analytics Preferences Unclassified Cookie Declaration About Cookies Necessary (0) Marketing (0) Analytics (0) Preferences (0) Unclassified (0) Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies. We do not use cookies of this type. Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers. We do not use cookies of this type. Analytics cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously. We do not use cookies of this type. Preference cookies enable a website to remember information that changes the way the website behaves or looks, like your preferred language or the region that you are in. We do not use cookies of this type. Unclassified cookies are cookies that we are in the process of classifying, together with the providers of individual cookies. We do not use cookies of this type. Cookies are small text files that can be used by websites to make a user's experience more efficient. The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages. Cookie SettingsDo you really wish to opt-out? Close
Cancel Confirm wpDiscuz0Would love your thoughts, please comment.x()x| ReplyInsertTừ khóa » Hàm In Trong Sql
-
Điều Kiện IN Trong SQL Server
-
Toán Tử AND OR NOT IN Trong SQL
-
Toán Tử IN Và NOT IN Trong SQL - Freetuts
-
IN Trong SQL Server | Comdy
-
Chi Tiết Bài Học 06. Từ Khóa IN Trong SQL - Vimentor
-
Toán Tử IN Và NOT IN Trong SQL - Vi
-
SQL Server: IN() Và NOT IN() | V1Study
-
Toán Tử IN Trong SQL - BAC
-
Toán Tử So Sánh LIKE, IN Trong SQL - Thủ Thuật
-
Top 26 Câu Lệnh Sql Mà Các Lập Trình Viên Và Nhà Data Nào Cũng Cần ...
-
ANY Và ALL Trong SQL - CodeHub
-
Toán Tử IN Trong SQL Server - Học Phân Tích Dữ Liệu ... - MasterMOS
-
Từ Khóa Trong SQL - Lập Trình Từ Đầu
-
Toán Tử ANY Và ALL Trong SQL - Lập Trình Từ Đầu