SQL (Structured Query Language ) is language created for querying from database.
Assume you have a database. You want to insert new stuff, update it, select some stuff or maybe delete it overtime.
Easy explained, the database consists of several tables, for example table of students:
The first column is unique id of record in the table (it is not number of the row as we can delete second row and row with id 3 will be second then).
Let’s start with selection. The basic syntax is:
/* comment in sql */ /* basic syntax ended with ; */ SELECT columns FROM table; /* examples */ /* 1 */ SELECT id FROM students; /* 2 */ SELECT name, surname FROM students; /* 3 */ SELECT id, name, surname, date_of_birth, has_bicycle FROM students; /* 4 */ SELECT * FROM students;
The first query SELECT id FROM students will return whole column with ids. The last 2 queries are the same, * character means everything (every column). The result of query number 2 will be: