MySQL Select Query

The SQL SELECT command is used to fetch data from MySQL database.

MySql SELECT Syntax:

  • You can use one or more tables separated by comma to include various condition using a WHERE clause. But WHERE clause is an optional part of SELECT command.
  • You can fetch one or more columns in a single SELECT query.
  • You can specify star (*) in place of fields. In this case SELECT will return all the fields
  • You can specify any condition using WHERE clause.
  • You can specify an offset using OFFSET from where SELECT will start returning records. By default offset is zero
  • You can limit the number of returned using LIMIT attribute.

Select all data

MySql select specific columns

MySql select specific rows

MySql select specific rows with AND operator

MySql select specific rows with OR operator

While fetching data you can write as complex SQL as you like. Procedure will remain same as mentioned above.

MySql select with LIMIT

The LIMIT clause can be used to limit the number of rows to be returned by the SELECT query. LIMIT takes one or two numeric arguments, which must both be non negative integer constants.With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):