Select Data From MySQL database in Php

Select Data From MySQL database in Php

In this article following things should be studied:

  • What is Select method in Php?
  • What types can be used?
  • How to use Select  query?.
  • Important NOTE.

What is Select method in Php?

The SELECT statement is used to select data from one or more tables. This could be for displaying some data from MySQL database.SELECT statement shows zero or more rows from one or more database tables or database views. Its a SQL query statement by which we can show data that has been INSERTED.



What Types can be used?

If you want to show or retrieve all the data from the table or all the columns data than:

SELECT * FROM table_name

If you want to specify the column names from a specific table to show:

SELECT column_name(s) FROM table_name

If multiple columns than you can separate the column names by comma.





How to use SELECT Query?

      As mentioned above there are two methods of selecting the tables from database. So the first type is:

Select  * :

This method is for selecting all the columns from the Table. This selection could be for showing the data or anything else.



          First of all you have to create a connection with the database and check if the connection is successful or not. Then initialize a variable in which we will be saving the query as a string.
In double inverted commas write the method you want to apply.

          In this article we are discussing about SELECT query, So you should start with it. Then use *, which will help the query to select all the columns from database. And after FROM give the name of table.


SELECT specific COLUMNS:

Second method of this SELECT query is by specifying the column names from which data should be shown to user. Because sometimes its case sensitive.



       After creating a secure connection and checking the connection, start the variable. In this after SELECT write down the names of column on which you want to apply the operation. 


Note:

And to know how to insert these values in the Database Click the Link.

To create connection to database. Click the Link.

Related Post: