WEBDEVELOPMENT Study Guide - Mysql

10 views3 pages

Document Summary

In situations in which you have multiple duplicate records in a table, it might make more sense to return only unique records, instead of fetching the duplicates. The sql distinct keyword is used in conjunction with select to eliminate all duplicate records and return only unique ones. The basic syntax of distinct is as follows: The following sql statement selects only distinct values from the city column: The distinct keyword only fetches the unique values. However, sometimes we need to retrieve just a subset of records. In mysql, this is accomplished by using the limit keyword. For example, we can retrieve the first five records from the customers table. By default, all results that satisfy the conditions specified in the sql statement are returned. You can also pick up a set of records from a particular offset. In the following example, we pick up four records, starting from the third position: