Setting conditions or constraints in SQL commands.
The WHERE clause is used to filter records. It is used to extract only those records that fulfill a specified condition.
Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Ex:
SELECT * FROM tblbooks WHERE book_year < 2000;
SELECT * FROM tblbooks WHERE book_publisher = 1;
SELECT a.book_title, b.auth_name
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE b.auth_name = 'Pitok Batolata';
The SQL AND Operator
The WHERE clause can contain one or many AND operators. The AND operator is used to filter records based on more than one condition.
SELECT a.book_title, b.auth_name
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE b.auth_name = 'Pitok Batolata' AND a.book_year;
The SQL OR Operator
The WHERE clause can contain one or more OR operators. The OR operator is used to filter records based on more than one condition.
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE b.auth_name = 'Pitok Batolata' OR b.auth_name = 'Kulas D. Malas';
The NOT Operator
The NOT operator is used in combination with other operators to give the opposite result, also called the negative result.
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE NOT b.auth_name = 'Pitok Batolata';
The SQL LIKE Operator
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.
There are two wildcards often used in conjunction with the LIKE operator:
- The percent sign % represents zero, one, or multiple characters
- The underscore sign _ represents one, single character
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE a.book_title LIKE 'THE%';
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE a.book_title LIKE '%song%';
The SQL IN Operator
The IN operator allows you to specify multiple values in a WHERE clause. The IN operator is a shorthand for multiple OR conditions.
The SQL BETWEEN Operator
The BETWEEN operator selects values within a given range. The values can be numbers, text, or dates. The BETWEEN operator is inclusive: begin and end values are included.
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE a.book_year IN (2023,2001)
ORDER BY a.book_title;
SELECT a.book_title, b.auth_name, a.book_year
FROM tblbooks a INNER JOIN tblbooks_authors c ON a.book_id = c.bookAuth_book_id
INNER JOIN tblbooks_authors_master b ON b.auth_id = c.bookAuth_author_id
WHERE a.book_year BETWEEN 1990 AND 2010;
Text : The SQL Where Clause
Ada Lovelace, World's First Programmer
Ada Lovelace, born Augusta Ada Byron on December 10, 1815, in London, England, is widely recognized as the world's first computer programmer. The daughter of the famous poet Lord Byron and Annabella Milbanke, Ada's upbringing was unique. Her mother, determined to distance Ada from her father's perceived madness, emphasized a rigorous education in mathematics and logic. This early focus on analytical thinking laid the foundation for Ada's future contributions to computing.
In 1833, Ada met Charles Babbage, a mathematician and inventor known as the "father of computers." Babbage had designed a mechanical calculating machine called the Difference Engine and was working on a more advanced machine, the Analytical Engine. Ada was fascinated by Babbage's work and quickly became his close collaborator. She translated an article by the Italian engineer Luigi Menabrea about the Analytical Engine and supplemented it with her own extensive notes.
Ada's notes on the Analytical Engine are considered groundbreaking. Among them, she included what is now recognized as the first algorithm intended to be processed by a machine, making her the first computer programmer. Her work demonstrated that the Analytical Engine could perform more than just mathematical calculations; it could also manipulate symbols and even compose music. Ada's visionary insights laid the groundwork for modern computing.
Despite her significant contributions, Ada's work was not fully appreciated during her lifetime. She faced numerous challenges, including societal expectations and health issues. Ada died at the young age of 36 on November 27, 1852. It wasn't until the mid-20th century that her contributions were fully recognized, and her legacy was cemented in the history of computing.
Today, Ada Lovelace's legacy lives on. The programming language "Ada," developed by the U.S. Department of Defense, was named in her honor. Every year, Ada Lovelace Day is celebrated on the second Tuesday of October to recognize the achievements of women in science, technology, engineering, and mathematics (STEM). Ada's story continues to inspire generations of women to pursue careers in these fields, highlighting the importance of diversity and inclusion in technology.
AI PILIPINO MUSIC
The YouTube channel AI PILIPINO MUSIC presents itself as a niche platform offering content that seems to span a unique blend of creativit...
-
There are two ways how to host our images: 1 - Image hosting websites - get the url for the image then use it as the src for the img ta...
-
Code used in the video discussion: Back end code - API (PHP) Text Version Front end Flutter code: TEXT VERSION
-
invoice.html < html lang = "en" > < head > < meta charset = "UTF-8" /> < meta name = ...