Query Select From a Database

Bookmark and Share

How to do a basic query from a MySQL database using PHP

1) Basic Query

SELECT * FROM table

2) Limit the Display of a Query

This displays only 10 rows of data

SELECT * FROM table LIMIT 10

This displays only 10 rows of data but starting from 0

SELECT * FROM table LIMIT 0,10

3) Order the Display of a Query

Alphanumerically order rows by a field using either Ascending (ASC) or Descending (DESC).

SELECT * FROM table ORDER BY field_id ASC

Please rate this post by clicking a star:

(2 votes, average: 4.00 out of 5)

Leave a Reply





Tags: , , , , ,