WHERE query using Boolean

Date Published: 22/08/2020 Published By: JaiSchool

While writing a WHERE query, when you simply give column name after WHERE keyword. It means true in boolean.

Understand it with example.

Make a database by running query

CREATE DATABASE jai_school;

Create a table in the database

CREATE TABLE mobiles(brand_name VARCHAR(30),price INT(10));

Insert data in the table

INSERT INTO mobiles(brand_name,price)VALUES("Samsung",80000);
INSERT INTO mobiles(brand_name,price)VALUES("Apple",140000);
INSERT INTO mobiles(brand_name,price)VALUES("Nokia",25000);
INSERT INTO mobiles(brand_name,price)VALUES("MI",14000);
INSERT INTO mobiles(brand_name,price)VALUES("Honor",9000);
INSERT INTO mobiles(brand_name,price)VALUES("Sony",18000);
INSERT INTO mobiles(brand_name,price)VALUES("Realme",14000);
INSERT INTO mobiles(brand_name,price)VALUES("Oneplus",28000);
INSERT INTO mobiles(brand_name,price)VALUES("Motorola",13000);

Table Image:

mysql table image
SELECT * FROM mobiles WHERE price;

When you run above query, you see only NULL values are filtered if any.

Publish A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *