1.9 Getting members according to primary key values

 

In the following product category table, ID field is the primary key. The task is to find ordinal numbers of members whose ID field values are 5, 7 and 10 respectively.

Category
ID
Name
Description

SPL script:

A
1 =connect(“db”)
2 =A1.query@x(“select * from Category”).keys(ID)
3 =A2.find@k([5,7,10])

A1 Connect to the database;
A2 Retrieve Category table from the database and set ID as the primary key;
A3 Find records whose primary key values are 5, 7 and 10 respectively and return a record sequence consisting of the three records. @k option treats the sequence type parameter passed in as a sequence of key values, which enables the function to return a sequence of multiple matching records.