Deal of the Day

Showing posts with label SQL Where. Show all posts
Showing posts with label SQL Where. Show all posts

Friday, 8 July 2011

SQL where Clause (Row Value Expressions)


Hi Guys,


Again thanks to Issak (my linkedin Friend) who made me re-call the new feature which was introduce in V5R4 for SQL Where clause
Quoting his words.
SQL WHERE clause usually checks if a condition is true, false or unknown. In the past, each condition was evaluated for a single value. Starting with V5R4 groups or "rows" of values can be evaluated at once. These groups of values are called "row value expressions." 


Below is a simple example with constants: 

SELECT * FROM DEPTBL WHERE (DEPT, BRANCH)=('Shipping', '0012M')

The number of columns must be equal and of compatible data types. 

Statement provides the same result as 

SELECT * FROM DEPTBL WHERE DEPT='Shipping' AND BRANCH='0012M' 


Please note the parentheses usage in first example. 

The same technique applies to IN (SELECT…) predicate. However a constant list is not allowed when using a row value expression in this case. 

This saves some coding, but could look confusing in the beginning. It is just the matter of preferences.



Do write me @ iSeriesblogs@gmail.com for any query or you can simply post comments below.

Happy Learning


Thursday, 30 June 2011

SQL400 for Beginners Part 2


Hi Guys....

Welcome back… Today I would share more in SQL400….

Getting Started

Interactive SQL/400 can be run from the Command line. Invoke STRSQL {Start SQL/400} and get at what looks like another command line, where we can key in SQL statements for immediate execution, and/or use the F4 Prompt function to navigate IBM DB2/400 data base, which is a version of UDB




SQL CONCEPTS
       Using basic SQL statements and clauses
       The SELECT clause
       Specifying a search condition using the WHERE clause
       ORDER BY clause
       Date/Time arithmetic
       Creating and using ALIAS names
       Creating descriptive labels using the LABEL ON statement
       Describing an SQL object using COMMENT ON