{"id":1107,"date":"2023-09-21T18:56:19","date_gmt":"2023-09-21T18:56:19","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1107"},"modified":"2023-10-01T19:15:39","modified_gmt":"2023-10-01T19:15:39","slug":"database-query-builder-where-not-clauses","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/database-query-builder-where-not-clauses\/","title":{"rendered":"Database: Query Builder \u2013 Where Not Clauses"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"808\" height=\"462\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-10.png\" alt=\"\" class=\"wp-image-1109\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-10.png 808w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-10-300x172.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/10\/image-10-768x439.png 768w\" sizes=\"auto, (max-width: 808px) 100vw, 808px\" \/><\/figure>\n\n\n\n<p>In SQL, the WHERE NOT clause is used to filter rows from a result set based on a condition that should not be met. It is a logical operator that negates the condition specified in the WHERE clause. The WHERE NOT clause is typically used in conjunction with other comparison operators or logical operators to perform more complex filtering in SQL queries.<\/p>\n\n\n\n<p>SELECT column1, column2, &#8230; FROM table WHERE NOT condition;<\/p>\n\n\n\n<p>The syntax for using the WHERE NOT clause in SQL is as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>SELECT<\/code>: Specifies the columns to be included in the result set.<\/li>\n\n\n\n<li><code>FROM<\/code>: Specifies the table from which to retrieve data.<\/li>\n\n\n\n<li><code>WHERE<\/code>: Specifies the condition that must be met for a row to be included in the result set.<\/li>\n\n\n\n<li><code>NOT<\/code>: Negates the condition specified in the WHERE clause.<\/li>\n<\/ul>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<p>Let\u2019s assume we have a table named \u201cemployees\u201d with columns such as \u201cemployee_id\u201d, \u201cfirst_name\u201d, and \u201csalary\u201d. If we want to select all employees whose salary is not greater than 5000, we can use the WHERE NOT clause as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT employee_id, first_name, salary\r\nFROM employees\r\nWHERE NOT salary > 5000;<\/code><\/pre>\n\n\n\n<p>This query will return all the rows from the \u201cemployees\u201d table where the salary is not greater than 5000.<\/p>\n\n\n\n<p>The WHERE NOT clause can be combined with other operators such as \u201c=\u201d, \u201c&lt;&gt;\u201d, \u201c&lt;\u201c, \u201c&gt;\u201d, \u201c&lt;=\u201d, \u201c&gt;=\u201d, and logical operators such as AND, OR to create more complex conditions for filtering data in SQL queries.<\/p>\n\n\n\n<p>It\u2019s important to carefully construct the condition and consider the logical implications when using the WHERE NOT clause to ensure the desired results are obtained.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In SQL, the WHERE NOT clause is used to filter rows from a result set based on a condition that should not be met. It is a&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[411],"class_list":["post-1107","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-database-query-builder-where-not-clauses"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1107"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1107\/revisions"}],"predecessor-version":[{"id":1110,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1107\/revisions\/1110"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}