A keyword in Structured Query Language, ANY returns a true value if any value in the subquery matches the value in the current row. In this way, ANY is similar to the IN keyword, except that IN only accepts the = operator and ANY accepts any relational operator. Let's look at an example.

SELECT * FROM
     books WHERE pub_year = ANY
     (SELECT birth_year from employees
      WHERE lname = "smith");

In this example, the query engine starts looking in the books table for books that have a publication year identical the same as the birth year of any person on the employees table whose last name is "smith." Say, there are two Smiths (Joe and Jane, born in 1971 and 1960 respectively). In this case, the query will return a record (or result) set of all books with publication dates of either 1971 or 1960. The same result set would have been returned had you replaced "= ANY" with "IN."

The real value of ANY is shown in the following example.

SELECT * FROM
     books WHERE pub_year < ANY
     (SELECT birth_year from employees
      WHERE lname = "smith");

In this case, the query will return all books with a publication year less than the birth year of any employee named "smith." The subquery grabs the birth years of Joe and Jane, which results in the main query returning a set of all books with publication years earlier than 1971 or 1960. Since 1971 is the 'larger' year, the 1960 value is sort of redundant.

Source:
Understanding SQL by Martin Gruber, ISBN 0895886448

A"ny (#), a. & pron. [OE. aeni, aeni, eni, ani, oni, AS., fr. an one. It is akin to OS. OHG. einic, G. einig, D. eenig. See One.]

1.

One indifferently, out of an indefinite number; one indefinitely, whosoever or whatsoever it may be.

Any is often used in denying or asserting without limitation; as, this thing ought not be done at any time; I ask any one to answer my question.

No man knoweth the Son, but the Father; neither knoweth any man the Father, save the Son. Matt. xi. 27.

2.

Some, of whatever kind, quantity, or number; as, are there any witnesses present? are there any other houses like it?

"Who will show us any good?"

Ps. iv. 6.

It is often used, either in the singular or the plural, as a pronoun, the person or thing being understood; anybody; anyone; (pl.) any persons.

If any of you lack wisdom, let him ask of God, . . . and it shall be given him. Jas. i. 5.

That if he found any of this way, whether they were men or women, he might bring them bound unto Jerusalem. Acts ix. 2.

At any rate, In any case, whatever may be the state of affairs; anyhow.

 

© Webster 1913.


A"ny, adv.

To any extent; in any degree; at all.

You are not to go loose any longer. Shak.

Before you go any farther. Steele.

 

© Webster 1913.

Log in or register to write something here or to contact authors.