0% found this document useful (0 votes)
50 views

To Restrict The Output by Including WHERE Conditions

The document provides instructions on how to restrict the output of a SELECT statement in MySQL to only include records where the 'Year' field contains the value '95' using a WHERE clause. It also gives an example of running a SELECT statement with a WHERE clause to filter the records returned from the Employee table to only those with a start_date of '95'.

Uploaded by

Laxman Thapa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views

To Restrict The Output by Including WHERE Conditions

The document provides instructions on how to restrict the output of a SELECT statement in MySQL to only include records where the 'Year' field contains the value '95' using a WHERE clause. It also gives an example of running a SELECT statement with a WHERE clause to filter the records returned from the Employee table to only those with a start_date of '95'.

Uploaded by

Laxman Thapa
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

To restrict the output by including WHERE conditions

To display only the records that contain the data '95' in the 'Year' field.

mysql> mysql> CREATE TABLE Employee( -> id int, -> first_name VARCHAR(15), -> last_name VARCHAR(15), -> start_date YEAR, -> end_date DATE, -> salary FLOAT(8,2), -> city VARCHAR(10), -> description VARCHAR(15 mysql> insert into Employee(id,first_name, last_name, start_date, end_D ate, salary, City, Description) -> values (1,'Jason', 'Martin', '1995', '2 0930725', 1234.56, 'Toronto', 'Programmer'); Query OK, 1 row affected (0.00 sec) mysql> mysql> insert into Employee(id,first_name, last_name, start_date, end_D ate, salary, City, Description) -> values(2,'Alison', 'Mathews', '1976', '1 9860221', 6661.78, 'Vancouver','Tester'); mysql> SELECT * FROM employee WHERE (start_date = 95);

Use a WHERE clause to combine row selection with column selec


SELECT first_name FROM employee -> WHERE id = 1 OR city = 'Vancouver';

Calculation in where clause


mysql> -> -> -> SELECT Name, InStock, OnOrder, Reserved FROM Topic WHERE (InStock+OnOrder-Reserved)>20 ORDER BY Name;

You might also like