Archive: MYSQL Tutorial
-
Aug 16, 2011
No CommentsHow to Use SQL JOIN to Retrieve Data from Multiple Tables : php2php.com
Summary: In this tutorial, you will learn how to use SQL JOIN to select data from multiple database tables. You will learn different kinds of JOIN including inner join, outer join, left and right joins. In the previous tutorial, you’ve learned how to retrieve data from one table by using SELECT statement. But normally you...
-
Aug 16, 2011
No Commentshow to Avoid Displaying NULL Values by Mapping to Other Values : php2php.com
The NULL was introduced by the creator of relational database model, Dr.E.F.Codd. In relational database management systems, NULL means unknown value or the value does not exist in database. MySQL supports NULL to represents the concept of missing information and inapplicable information. Sometimes, we have to display the stored data which has NULL value to...
-
Aug 16, 2011
No CommentsCompare Two Tables to Find Unmatched Records : PHP2PHP.com
In database programming, sometimes you have to compare two tables (or two views of more than two tables) to find the unmatched records and the difference between two records in two tables with the same identity. As an example, in database migration you have a legacy database and new database with two different database schemata....
-
Aug 16, 2011
No CommentsSelect the Nth Highest Record in a Database Table : PHP2php.com
Summary: In this tutorial, you will learn how to select the Nth highest record in a database table by using various techniques. These techniques are very useful, for instance you may want to see the product which is second most expensive in Products database table. The first idea is we get the Nth highest result...
-
Aug 16, 2011
No CommentsCount Records in a Database Table in MySQL : php2php.com
Summary: In this tutorial, you will learn how to use an aggregate function called MySQL COUNT to count number of records in a database table. In order to count a number of records in a database table we can use standard SQL COUNT function. The syntax is quite simple as follows: 1 SELECT COUNT(*) AS...
-
Aug 16, 2011
No CommentsUsing Regular Expression in MySQL : How to Use Regular Expression in MySQL : PHP2PHP.com
Summary: In this tutorial, you will learn how to use regular expression with SQL SELECT statement to retrieve data based on complicated patterns. Regular expression is a powerful tool which gives you a concise and flexible way to identify strings of text, for instance characters, words or patterns of characters. As an example, you can...
-
Aug 16, 2011
No CommentsSelect Random Records in Database Table at php2php.com
Summary: In this tutorial, you will learn various techniques to select random records from a database table in MySQL. MySQL does not have any automatic way to select random items from a database table. In some programming tasks, it is required and very useful to select random items from a result set such as: You’ll need...
-
Aug 16, 2011
No CommentsMySQL Copy Database Table tutorial on php2php.com
Summary: In this tutorial, you will learn how to copy data from one table into a new table by using SQL CREATE TABLE and SELECT statement. Copying data from an existing table to a new one is useful in some cases such as backing up data, create a copying of real data for testing. In order...
-
Jul 26, 2011
1 CommentHow to Use MySQL REPLACE to Insert or Update Data
Summary: In this tutorial, you will learn how to use MySQL REPLACE statement to insert or update data in database tables. MySQL REPLACE statement is a MySQL extension to SQL standard. MySQL REPLACE works like INSERT statements with the following rules: If the record being inserting does not exist, MySQL REPLACE will insert a new...
-
Jul 26, 2011
No CommentsDeleting Records from Tables Using MySQL DELETE
Summary: The MySQL DELETE statement not only allows you to delete record from one table but also multiple tables. In this tutorial, you will learn how to use MySQL DELETE statement with examples. To remove all rows or records from a database table you use MySQL DELETE statement. The following illustrates MySQL DELETE statement: 1...
-
Jul 26, 2011
No CommentsUpdating Data in Database Tables
Summary: Updating existing data is one of the most important task when you work with database. In this tutorial, you will learn how to use MySQL UPDATE statement to update data in database tables. SQL UPDATE statement is used to update existing data in database tables. It can be used to change values of single...
-
Jul 26, 2011
No CommentsInserting Data into Database Tables
Summary: In the previous tutorials you learn different ways to query data from database table by using SQL SELECT statement. Are you wonder that how data is added into those table? In this tutorial, you will learn do it by using SQL INSERT statement. INSERT Statement INSERT statement allows you to insert one or more...
-
Jul 26, 2011
No CommentsMySQL HAVING
Summary: In this tutorial, you will learn how to use MySQL HAVING clause to specify a filter condition for a group of records or an aggregate. Introducing MySQL HAVING clause The MySQL HAVING clause is an optional part of and used only with the SQL SELECT statement. The MySQL HAVING clause specifies a filter condition...
-
Jul 26, 2011
No CommentsMySQL GROUP BY
Summary: In this tutorial, you will learn how to use MySQL GROUP BY to group selected records into a set of summary records by the one or more column’s value or expression. Introducing to MySQL GROUP BY clause The MySQL GROUP BY clause is used with SQL SELECT statement to to group selected records into a set...
-
Jul 26, 2011
No CommentsMySQL LEFT JOIN
Summary: In this tutorial, you will learn how to use MySQL LEFT JOIN clause to retrieve data from more than one table. Introducing to MySQL LEFT JOIN The MySQL LEFT JOIN clause is an optional element of the SQL SELECT statement to allow you to retrieve data from additional tables. The MySQL LEFT JOIN clause...
-
Jul 26, 2011
No CommentsMySQL INNER JOIN
Summary: In this tutorial, you will learn how to use MySQL INNER JOIN clause to select data from multiple tables based on join conditions. Introducing MySQL INNER JOIN clause The MySQL INNER JOIN clause is an optional part of SQL SELECT statement. The MySQL INNER JOIN clause appears immediately after the FROM clause. Before using...
-
Jul 26, 2011
No CommentsCombining Result Sets with MySQL UNION
Summary: In this tutorial, you will learn how to use MySQL UNION statement to combine two or more result sets from multiple SQL SELECT statements into a single result set. Like SQL standard, MySQL UNION allows you to combine two or more result sets from multiple tables together. The syntax of using MySQL UNION is...
-
Jul 26, 2011
No CommentsHow to Use MySQL LIKE to Select Data Based on Patterns Matching
Summary: MySQL provides LIKE operator in SQL standard. The MySQL LIKE operator is commonly used to select data based on patterns matching. Using MySQL LIKE in appropriate way is essential to increase application’s performance. In this tutorial, you will learn how to use MySQL LIKE and when to avoid using it to increase the speed...
-
Jul 26, 2011
No CommentsWorking with Tables – Part II
Summary: following with the previous tutorial on how to create database tables in MySQL, in this tutorial, you will learn how to modify and remove existing database tables. Altering Table Structures Beside creating table, MySQL allows you to alter existing table structures with a lot of options.To modify existing database table structure you use the...
-
Jul 26, 2011
No CommentsRetrieving Data in a Range Using SQL BETWEEN
Summary: In this tutorial, you will learn how to retrieve data from database tables which its value are in a range by using SQL BETWEEN operator. SQL BETWEEN Operator Syntax The SQL BETWEEN operator allows you to retrieve values within a specific range. the SQL between must be used in the WHERE clause of the SQL SELECT statement. The following illustrates...