Discussion :: Introduction to SQL - General Questions (Q.No.25)
|Shiwam said: (Sep 19, 2011)|
|Mohini said: (Oct 5, 2011)|
|Ganesh said: (Apr 8, 2012)|
|The IN function helps reduce the need to use multiple OR conditions.
The syntax for the IN function is:
WHERE column1 in (value1, value2, .... value_n);
This SQL statement will return the records where column1 is value1, value2..., or value_n. The IN function can be used in any valid SQL statement - select, insert, update, or delete.
The following is an SQL statement that uses the IN function:
WHERE supplier_name in ( 'IBM', 'Hewlett Packard', 'Microsoft');
This would return all rows where the supplier_name is either IBM, Hewlett Packard, or Microsoft. Because the * is used in the select, all fields from the suppliers table would appear in the result set.
|Ranju said: (Jun 16, 2016)|
|Please explain it in some other way.|
|Hrishi said: (Nov 26, 2016)|
|Other 3 have a syntax error.|
|Vkhan said: (Jan 31, 2017)|
|Thank you so much for explaining this.|
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.