
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we use a combination of logical operators while creating MySQL views?
MySQL views can be created by using a combination of logical operators like AND, OR, and NOT. It can be illustrated with the help of following examples −
Example
mysql> Create or Replace View Info AS select ID, Name, Address , Subject FROM Student_info WHERE (Subject = 'Computers' AND ADDRESS = 'Delhi') OR (Subject = 'History' AND Address = 'Amritsar'); Query OK, 0 rows affected (0.11 sec) mysql> Select * from Info; +------+-------+---------+-----------+ | ID | Name | Address | Subject | +------+-------+---------+-----------+ | 133 | Mohan | Delhi | Computers | +------+-------+---------+-----------+ 1 row in set (0.00 sec)
- Related Articles
- How can we use logical operators while creating MySQL views?
- Can we use {} while creating a MySQL table?
- How can we create MySQL views?
- How can we create MySQL views with column list?
- How can we create MySQL views without any column list?
- While creating a MySQL table use the reserved keyword ‘Key’
- How can we see the list of views stored in a particular MySQL database?
- What is MySQL NOT NULL constraint and how can we declare a field NOT NULL while creating a table?
- Where MySQL views can be inconsistent and how can we ensure their consistency?
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- What is MySQL GENERATED COLUMN and how to use it while creating a table?
- Python Logical Operators
- Java Logical Operators
- Perl Logical Operators
- Creating views in MongoDB

Advertisements