How to Use ANY Keyword in SQL

In this article I am going to explain how to use any keyword in SQL.
  • 2240

Introduction

In this article I am going to explain how to use ALL Keyword in SQL. A select statement known as subquery if it is codded within another SQL statement. Subquery can return a single value or a result set. This result set may contain a single column or more than one column.

There are four way to create subquery in a SELECT statement.

  • In WHERE Clause
  • In HAVING Clause
  • In FROM Clause
  • In SELECT Clause

ALL Keyword

ANY Keyword in SQL is used to test that a comparison condition is true for one or more of values return by subquery. We use ANY keyword with comparison operators like >,<,>= and <= .

ANY and SOME are equivalent keyword. Keyword ANY and SOME provide same output.

Example

select vendorname,mcninvoices.vendorid,invoicetotal

from mcnvendors join mcninvoices

on mcnvendors.vendorid = mcninvoices.vendorid

where invoicetotal  < ANY

( select invoicetotal

from mcninvoices

where vendorid=24

Output

Clipboard02.jpg


© 2018 DotNetHeaven. All rights reserved.