Query to find the second highest column value in a table
Second Highest Salary in MySQL and SQL Server
Write a SQL query to get the second highest salary from the Employee table. For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return NULL. You can write SQL query in any of your favorite database e.g. MySQL, Microsoft SQL Server or Oracle.
Query to find the second lowest column value in a table
In this ms sql server tutorial you will learn query to find the second lowest column value in a table.
Select the Nth Highest Record in a Database Table
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.
Changing Column Size
Changing the size of a column in MySQL is pretty easy. By using alter table and modify you are able to choose a column on a specified table and resize it. Learn how to resize a MySQL column.
Display records in multi column format with PHP
This two videos explain how to populate records from the MySQL database and display them on the page in the multi column format. Each column follows the ascending order of the records from the previous column. In this example we are using Table, but you can use any HTML element to display records in multi column format.
How to Change a Column Name
If you have created a database and decide later that one of the column names you chose isn't exactly what you want, you can rename it. You do this using alter table and change. Together they can be used to rename a MySQL column.
Changing Table Structure Using MySQL ALTER TABLE
Changing existing table structure is a very important task especially when the current table structure no longer reflects the new business's needs. In this tutorial, you will learn about MySQL ALTER TABLE statement to change existing table structure such as add or drop column, change column attribute and rename table.
Once you have your table data organized, the next step is to figure out the data type. There are three main types : text, numbers, and Dates/Times. Choosing the column types specifies what information can or can't be stored in a table cell. Using the most correct option for each column is important as it may affect the database's overall performance.
Reset Auto-Increment In MySql
In this post i going to demonstrate how to reset auto-increment value in MySql. There is no doubt MySQL provides an awesome feature called auto-increment. We assign the auto-increment attribute to a column of a table. Every time new row is inserted it increments the value. By default the auto-increment column is primary key of a table.
MySQL ALTER command is very useful when you want to change a name of your table, any table field or if you want to add or delete an existing column in a table.
Identifiers & Qualifiers
In this section you will learn about describing the allowable syntax for identifiers in MySQL. The identifiers are Database, table, index, column and alias name. The following table describes the maximum length for each type of identifier.
Copying data from one table to another in sql
In this short tutorial, I am going to show you how to transfer data from any column in a table to another in sql using php.
Fixing column encoding mess in MySQL
Just had an interesting issue with an encoding mess on a column containing non-ASCII text. The solution was not immediately obvious so I decided it's worth sharing.
MySQL Column type database
In this session you will learn how to support number of column in MySQL . MySQL supports the numeric type , Date and time type, and String type (char) database.
Search and Replace Data
If you have imported your database, only to find that funny characters have appeared, you can issue the following mysql statement inside PHPMyAdmin to find and replace.
Handling MySQL NULL Values
We have seen SQL SELECT command along with WHERE clause to fetch data from MySQL table. But when we try to give a condition which compare field or column value to NULL it does not work properly.
Why is a SELECT that uses CONCAT() so slow?
When running queries on a large table and using a function like CONCAT() in the WHERE clause, the queries can be much slower than when the function is not used. This is usually caused when the function is used on an indexed column.
When you select the data from more than one table this is known as Joining. A join is a SQL query that is used to select the data from more than one table or views. When you define multiple tables or views in the FROM clause of a query the MySQL performs a join that linking the rows from multiple tables together.
Using MySQL JOINS
Thus far we have only been getting data from one table at a time. This is fine for simple takes, but in most real world MySQL usage you will often need to get data from multiple tables in a single query.
You can use multiple tables in your single SQL query. The act of joining in MySQL refers to smashing two or more tables into a single table.
Understanding MySQL TIMESTAMP
MySQL TIMESTAMP is a temporal data type that store combination of date and time values. In this tutorial you will learn how TIMESTAMP values are stored in the database and how to use automatic initialization and automatic update to create created on and last changed on column in a table.