Query Select From a Database

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

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Next Post » »