quick links

MySQL Filtering data operator

WHERE, AND, OR, IN, NOT IN, BETWEEN, LIMIT, LIKE are filter data operators

WHERE

  • WHERE clause to filter rows based on specified conditions.
  • SELECT lastname, firstname, jobtitle FROM employees WHERE jobtitle = 'Sales Rep';

AND

  • where employee_name = 'Alex' and age > 20

OR

  • where employee_name ='Alex' or age > 40

IN

  • The IN operator allows you to determine if a specified value matches any one of a list or a subquery.
  • where employee_name in ('Alex','Roy')

NOT IN

  • where employee_name not in ('Alex','Roy' )

BETWEEN

  • The BETWEEN operator allows you to specify a range to test. We often use the BETWEEN operator in the WHERE clause of the SELECT, INSERT, UPDATE, and DELETE statements.
  • where employee_id between 2 and 4

LIMIT

  • The LIMIT clause is used in the SELECT statement to constrain the number of rows in a result set
  • SELECT column1,column2,... FROM table LIMIT offset , count;
  • The offset specifies the offset of the first row to return. The offset of the first row is 0, not 1.
  • The count specifies the maximum number of rows to return.

LIKE

  • For wildcard filtering "Like" operator is used. Within a search string, % means match any number of occurrences of any character
  • where employee_name like 'J%' (filter name start with J)
  • where employee_name like '%a%' (filter all names containing letter a)
  • where employee_name like '%y' (all names ending with letter y)

IS NULL

  • To test whether a value is NULL or not, you use the IS NULL operator. of the IS NULL operator: value IS NULL
  • WHERE salesrepemployeenumber IS NULL
  • WHERE salesrepemployeenumber IS NOT NULL
 

About Us

Joomla Web Solution

We love working with PHP, HTML5, CSS3, jQuery and the most-loved content management framework in the world, Joomla!

LIKE US ON FACEBOOK