Archive: Mysql Interview Questions
-
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....
-
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...
-
Jul 26, 2011
No CommentsSelecting Data with SQL IN
Summary: In this tutorial, you will learn how to select a result set which their values match any one of a list of values by using SQL IN operator. SQL IN Operator Syntax The SQL IN operator allows you to select values that match any one of a list of values. The usage of the...
-
Jul 26, 2011
No CommentsHow to Use MySQL Limit to Constrain Number of Returned Records
Summary: In this tutorial, you will learn how to use MySQL LIMIT clause to constrain number of returned records in SQL SELECT statement. Most of the times, when you work with master data tables which contain thousand to millions of records and you don’t want to write a query to get all the data from...
-
Jul 26, 2011
No CommentsHow to Use MySQL Distinct to Eliminate Duplicate Rows
Summary: In this tutorial, you will learn how to use MySQL DISTINCT with SELECT statement to eliminate duplicate records in the selected result set. Sometimes when retrieving data from database table, you get duplicate records which are not expected. In order to remove those duplicate records, you need to use DISTINCT keyword along with SELECT...
-
Jul 26, 2011
No CommentsUsing MySQL SELECT Statement to Query Data
Summary:In this tutorial, you will learn how to MySQL SELECT statement to query data from database tables. MySQL SELECT Statement Syntax In order to retrieve data from MySQL database table you need to use MySQL SELECT statement. The following illustrates MySQL SELECT statment syntax: 1 SELECT column_name1,column_name2... 2 FROM tables 3 [WHERE conditions] 4 [GROUP BY group...
-
Jul 26, 2011
No CommentsManaging Database Index in MySQL
Summary: In this tutorial, you will learn how to work with database index in MySQL. You will learn how to use database index properly to speed up the data retrieval and what SQL statements to use to create or drop database index. Database indexes help to speed up the retrieval of data from MySQL database server. When retrieving...