Friday, October 19, 2012

Query SQL SELECT and INSERT


SELECT command in SQL is used to display the field in the table that we want.

1. Command to display all the existing columns in a table.

            Example :

            Display all the existing columns in Produk table.

      $query=”Select * from produk”;

      $command=mysql_query($query);

2. Command to display a particular column in a table.         
 
Example:

            Display Nama Produk and Harga

            $query=”Select NamaProduk,Harga from produk”;

      $command=mysql_query($query);


INSERT command in SQL is used to enter the field in the table.

Example:

Insert  field in the Produk table:

$query=”insert into (KodeProduk,NamaProduk,Harga,Diskon) values(‘12345’,’Soap’,4000,10)”;

            $command=mysql_query($query);

No comments:

Post a Comment