Clause - Mitsubishi Electric MELSEC iQ-R-R00CPU User Manual

Melsec iq-r series cpu module application user's manual
Table of Contents

Advertisement

Clause

WHERE
This command conducts search with conditions.
Syntax
• To specify a condition
WHERE [condition]
• To specify an exception
WHERE NOT [condition];
• To specify two conditions with AND
WHERE [condition 1] AND [condition 2];
• To specify two conditions with OR
WHERE [condition 1] OR [condition 2];
■Operators that can be used in [condition]
Item
Description
=
Equals
!=
Not equal to
<>
Not equal to
>
Greater than
>=
Greater than or equal to
<
Less than
<=
Less than or equal to
IN
Brings the conditions to be set together.
BETWEEN
Specifies the range to be output.
■Application example
• To output a record with the fld1 value of 1 to 100 of table1
SELECT * FROM "table1" WHERE "fld1" BETWEEN 1 AND 100;
• To output fld1 and fld3 of the record with the fld3 value other than abc of table1
SELECT "fld1", "fld3" FROM "table1" WHERE NOT "fld3" = 'abc';
GROUP BY
This command groups elements.
Syntax
GROUP BY [numeric expression]
■Application example
• To group Table1 according to the value of fld1 and aggregate the number of records
SELECT COUNT(*) FROM "table1" GROUP BY "fld1";
HAVING
This command narrows down a search using the result of the aggregate function.
Syntax
HAVING [numeric expression]
■Application example
• To output only the groups whose total value is 50 or less
SELECT SUM ("fld2") FROM "table1" GROUP BY "fld1" HAVING SUM ("fld2") < 50;
APPX
1000
Appendix 14 List of Available SQL Commands for CPU Module Database Access Function
Syntax
[numeric expression 1] = [numeric expression 2]
[numeric expression 1] != [numeric expression 2]
[numeric expression 1] <> [numeric expression 2]
[numeric expression 1] > [numeric expression 2]
[numeric expression 1] >= [numeric expression 2]
[numeric expression 1] < [numeric expression 2]
[numeric expression 1] <= [numeric expression 2]
IN ([numeric expression 1], [numeric expression 2], , [numeric
expression 3])
[numeric expression 1] BETWEEN [numeric expression 2] AND
[numeric expression 3]

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents