In SQL, a table consists of two major components: rows and columns.
A row represents a single record or entry in the table. Each row contains data for each column. You can think of it as a horizontal line of values.
Each row is unique and identified by a primary key (e.g., id
column).
A column represents a single data field in the table. It contains values of the same type across all rows (for example, all name
entries in the students
table).
Columns are defined by their data types, like INT
, VARCHAR
, etc.
ID | Name | Age | Grade |
---|---|---|---|
1 | John | 22 | A |
2 | Emma | 23 | B |
In this example, each row represents a student, and the columns represent the student's ID, Name, Age, and Grade.
You can access a specific row or column in SQL using the SELECT
statement. Hereβs an example to fetch a specific row based on the id column:
SELECT * FROM students WHERE id = 1;
This query will return the row with id = 1 from the students table.
Can you write an SQL query to select all names of students who are older than 21?
(Test your SQL queries in a SQL editor or database management tool!)
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!