官术网_书友最值得收藏!

Retrieving data

Now that we have inserted data into the students, courses, and students_courses tables, let us look at the different mechanisms of retrieving data, we will be using the SELECT command to retrieve the data. The SELECT statement would expect two things as a minimum, the first would be what to retrieve and the second would be where to retrieve it. The simplest SELECT command would be to retrieve all the student records from the students table:

Retrieving data

In this query, we are using * to retrieve the data for all the columns from the students table, this is not a preferred method of retrieving data. The preferred method for data retrieval is by mentioning the individual columns separated by a comma (,) after the SELECT clause:

Retrieving data

In this query, we are selecting the student_id, first_name, and last_name columns from the students table. As we are not filtering the data yet, SELECT statements would return every student record that is in the students table. We can use the LIMIT clause to retrieve a certain number of records:

Retrieving data

In this query, we are retrieving the data from the students table and we are retrieving the student_id, first_name, and last_name columns; however, rather than retrieving all the rows, we are only retrieving a single row. To retrieve the next row, we could still use the limit, but we would use LIMIT clause accompanied by the OFFSET clause. The OFFSET clause determines the starting point as to where the records should start from, while the LIMIT clause determines the number of records that would be retrieved.

主站蜘蛛池模板: 兴宁市| 和静县| 手机| 额尔古纳市| 佳木斯市| 板桥市| 饶平县| 阿城市| 隆回县| 九江县| 资阳市| 临夏市| 博爱县| 开原市| 樟树市| 古蔺县| 霍林郭勒市| 华坪县| 赣州市| 原阳县| 富锦市| 富川| 鹤岗市| 略阳县| 隆尧县| 准格尔旗| 定兴县| 屏东市| 咸阳市| 正宁县| 鄂伦春自治旗| 马公市| 宝应县| 土默特左旗| 垣曲县| 罗城| 墨竹工卡县| 冷水江市| 长岛县| 高碑店市| 泰兴市|