Posted by anbarasank on June 4th, 2011 at 1:16 pm
Assume in a table, some of the columns may contain duplicate values. This is not a problem; however, sometimes you will want to list only the different (distinct) values in a table.
DISTINCT helps to eliminate duplicates. If a query returns a result that contains duplicate rows, you can remove duplicates to produce a result set in which every row is unique. To do this, include the keyword DISTINCT after SELECT and before the output column list.
SELECT DISTINCT field_name FROM...
Posted by anbarasank on June 4th, 2011 at 12:22 pm
The DELETE statement is used to delete records in a table.
If you want to delete a record from any MySQL table then you can use SQL command DELETE.
DELETE FROM table_name WHERE Clause condition
If WHERE clause is not specified then all the records will be deleted from the given MySQL table. Ok, in the below example we will delete the row of id as 1.
// Make a MySQL Connection
// Delete first row from the "employee" table
$delete_q = "DELE...
Posted by anbarasank on June 4th, 2011 at 11:28 am
The UPDATE statement is used to update records in a table.
There may be a requirement where existing data in a MySQL table need to be modified. You can do so by using SQL UPDATE command. This will modify any field value of any MySQL table.
UPDATE table_name SET field1=new-value1, field2=new-value2
You have to be very careful when updating records this way and double check your syntax, as it is very easy to inadvertently overwrite several records.
Posted by anbarasank on June 4th, 2011 at 11:12 am
The AND operator displays a record if both the first condition and the second condition is true.
The OR operator displays a record if either the first condition or the second condition is true.
Example for AND :
Now we want to select only the record with the name equal to "learnwebdevelopment" AND the id equal to 1:
We use the following SELECT statement:
$select_q = "SELECT * FROM employee WHERE name='learnwebdevelopment' AND id=1";
$select_r = mysql...
Posted by anbarasank on June 4th, 2011 at 10:46 am
We have seen MySQL SELECT command to fetch data from MySQL table. We can use a conditional clause called WHERE clause to filter out results. Using WHERE clause we can specify a selection criteria to select required records from a table.
If we wanted to select only certain entries of our table, then we would use the keyword WHERE.
SELECT * FROM table_name WHERE condition;
*You can use one or more tables separated by comma to include various condition using a WHERE clause. B...
Posted by anbarasank on June 4th, 2011 at 10:11 am
The INSERT statement is used to insert new records in a table.
It is possible to write the INSERT statement in two forms.
The first form doesn't specify the column names where the data will be inserted, only their values:
INSERT INTO table_name VALUES (value1, value2, value3,...valueN)
The second form specifies both the field names and the values to be inserted:
INSERT INTO table_name ( field1, field2,...fieldN )VALUES( value1, value2,...valueN );
In below exampl...
Posted by anbarasank on June 4th, 2011 at 9:46 am
SELECT, which is used to get information from the database, so that its data can be used in our PHP script.
SELECT * FROM table_name;
SELECT column_name(s) FROM table_name
Note: SQL is not case sensitive. SELECT is the same as select.
In this example we will select everything in our table "employee" and put it into a nicely formatted HTML table. Assume the ‘employee’ table has three fields id, name and age.
Remember, if you don't understand the HTML or PHP ...
Posted by anbarasank on June 4th, 2011 at 8:21 am
MySQL is currently the most popular open source database server in existence. On top of that, it is very commonly used in conjunction with PHP scripts to create powerful and dynamic server-side applications.
As the world's most popular open source database, MySQL is used by a wide range of organizations to manage their data. In this section, you'll be getting started with MySQL.You will learn how to use MySQL effectively to get your work done more ...