{"id":799,"date":"2014-12-08T17:39:40","date_gmt":"2014-12-09T00:39:40","guid":{"rendered":"https:\/\/blogs.ubc.ca\/coetoolbox\/?page_id=799"},"modified":"2016-10-24T11:02:26","modified_gmt":"2016-10-24T18:02:26","slug":"comparison-keywords","status":"publish","type":"page","link":"https:\/\/blogs.ubc.ca\/coetoolbox\/databases\/comparison-keywords\/","title":{"rendered":"Comparison Keywords"},"content":{"rendered":"<h2>IS NULL<\/h2>\n<p>A column value is NULL if it does not exist. The IS NULL operator is used to display all the rows for columns that do not have a value.<\/p>\n<p>SELECT *<br \/>\nFROM Students<br \/>\nWHERE StudentName <span style=\"color: #0000ff;\">IS NULL<\/span><\/p>\n<p>Note: it is not possible to test for NULL values with comparison operators such as =. The result of any arithmetic expression involving null is null.<\/p>\n<h2>BETWEEN<\/h2>\n<p>The BETWEEN\u00a0operator is used to compare data for a range of values.<\/p>\n<p style=\"padding-left: 30px;\">SELECT *<br \/>\nFROM Students<br \/>\nWHERE Year <span style=\"color: #0000ff;\">BETWEEN<\/span> 2000 <span style=\"color: #0000ff;\">AND<\/span> 2015<\/p>\n<h2>IN<\/h2>\n<p>The IN operator is used when you want to match a column with one of several possible values.<\/p>\n<p style=\"padding-left: 30px;\">SELECT *<br \/>\nFROM Students<br \/>\nWHERE Program <span style=\"color: #0000ff;\">IN<\/span> (&#8216;MM&#8217;, &#8216;MMOR&#8217;)<\/p>\n<h2>LIKE<\/h2>\n<p>The LIKE keyword is used to search entries with a given pattern. For example, the following query returns all the courses with id starting with BAMS.<\/p>\n<p style=\"padding-left: 30px;\">SELECT *<br \/>\nFROM Courses<br \/>\nWHERE CourseID <span style=\"color: #0000ff;\">LIKE<\/span> &#8216;BAMS<span style=\"color: #ff0000;\">%<\/span>&#8216;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <em><span style=\"color: #999999;\">(&#8216;BAMS<span style=\"color: #ff0000;\">*<\/span>&#8216; for MS Access)<\/span><\/em><\/p>\n<p>The syntax for a condition with LIKE operator is:<\/p>\n<p style=\"padding-left: 30px;\"><em>expression<\/em> LIKE <em>pattern<\/em><\/p>\n<p>where <em>expression<\/em> is a character expression such as a column or field, and <em>pattern<\/em> is a character expression that contains pattern searched. The patterns are expressed using wildcard characters:<\/p>\n<ul>\n<li><span style=\"color: #ff0000;\"> %<\/span> allows you to match any string of any length, including zero length (<span style=\"color: #ff0000;\">*<\/span> for MS Access)<\/li>\n<li><span style=\"color: #ff0000;\">_<\/span> allows you to match on a single character (<span style=\"color: #ff0000;\">?<\/span> for MS Access)<\/li>\n<\/ul>\n<p>See more about wildcards here: <a href=\"http:\/\/www.w3schools.com\/sql\/sql_wildcards.asp\" target=\"_blank\">SQL wildcards<\/a>. See more about LIKE operator: <a href=\"http:\/\/www.techonthenet.com\/sql\/like.php\" target=\"_blank\">SQL LIKE Condition<\/a>, <a href=\"http:\/\/www.w3schools.com\/sql\/sql_like.asp\" target=\"_blank\">SQL LIKE Operator<\/a>.<\/p>\n<p><strong>EXISTS<\/strong> and <strong>UNIQUE<\/strong> keywords are explained in the <a title=\"Nested Queries\" href=\"https:\/\/blogs.ubc.ca\/coetoolbox\/databases\/nested-queries\/\">Nested Queries<\/a> section.<\/p>\n<p>See more about operators: <a href=\"https:\/\/docs.oracle.com\/html\/A95915_01\/sqopr.htm\" target=\"_blank\">Oracle SQL Operators<\/a>, <a href=\"http:\/\/beginner-sql-tutorial.com\/sql-like-in-operators.htm\" target=\"_blank\">SQL Comparison Keywords<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IS NULL A column value is NULL if it does not exist. The IS NULL operator is used to display all the rows for columns that do not have a value. SELECT * FROM Students WHERE StudentName IS NULL Note: it is not possible to test for NULL values with comparison operators such as =. [&hellip;]<\/p>\n","protected":false},"author":22982,"featured_media":0,"parent":74,"menu_order":4,"comment_status":"open","ping_status":"open","template":"page-templates\/full-width.php","meta":{"footnotes":""},"class_list":["post-799","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/pages\/799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/users\/22982"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/comments?post=799"}],"version-history":[{"count":8,"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/pages\/799\/revisions"}],"predecessor-version":[{"id":1525,"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/pages\/799\/revisions\/1525"}],"up":[{"embeddable":true,"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/pages\/74"}],"wp:attachment":[{"href":"https:\/\/blogs.ubc.ca\/coetoolbox\/wp-json\/wp\/v2\/media?parent=799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}