DEV Community

Talha Munir πŸ‡΅πŸ‡Έ
Talha Munir πŸ‡΅πŸ‡Έ

Posted on

Description of important clauses in SQL and Apache age query format part 1

The blog follows the description of some valid clauses in SQL and then in Apache age.

Match clause:

Match clause is used for searching specific values. It is mostly used with Against function. For example in below query searches the table student where the name column contains the word Talha:
SQL:

SELECT * FROM student WHERE MATCH(name) AGAINST(β€˜Talha’);
Enter fullscreen mode Exit fullscreen mode

Create clause:

The create clause is used to create a new table, index, or view in the database. E.g. the following query creates a new table student with fields id, name, and email.
SQL:

CREATE TABLE student (
id INT PRIMARY KEY,
name VARCHAR(255),
email VARCHAR(255)
);

Enter fullscreen mode Exit fullscreen mode

Set clause:

The set clause is used to update the values in a table. E.g. the following query updates the email address of the student whose id is 1
SQL:

UPDATE student SET email='new@email.com' WHERE id=1;
Enter fullscreen mode Exit fullscreen mode

Delete Clause:

Delete clause is used to remove rows from the table. E.g following query removes all rows from the table student whose email column is empty
SQL:

DELETE FROM student where email = β€˜β€™;
Enter fullscreen mode Exit fullscreen mode

Merge Clause:

The merge clause combines data from 2 or more sources into a single table. It is mostly used with union or union all operators. Just like following SQL statement combines data from student and courses tables.
SQL:

SELECT id, name β€˜student’ as type FROM students
UNION
SELECT id, courseName, 'course' as type FROM courses;
Enter fullscreen mode Exit fullscreen mode

Call clause:

The call clause is used to execute a stored method. For example the following query calls the a stored procedure get_student_information.
SQL:

CALL get_student_information(1);
Enter fullscreen mode Exit fullscreen mode

Yield clause:

Yield clause is used to return data from a stored method or a function. For example the following function is used to return a result set containing information of students.
SQL:

CREATE PROCEDURE get_student_information (id INT)
BEGIN
SELECT * FROM students WHERE id = id;
YIELD;
END
Enter fullscreen mode Exit fullscreen mode

In the next part we will discuss clause usage in Apache age.

Top comments (0)