ITSourceCode.com

Custom Search

SQL ORDER BY Keyword

It defines how the records are to be sorted. By default, it is to order in ascending order(ASC). If we want to sort in descending order, we can use DESC after the column name.   Syntax:   < View plain text > sql SELECT column_name, column_name FROM table_name ORDER BY column_name ASC/DESC, column_name ASC/DESC;   […]

SQL UNIQUE Constraint

This unique constraint identifies each record in a table. A PRIMARY KEY constraint itself defines UNIQUE constraint. The basic difference between UNIQUE and PRIMARY KEY constraint is that we can have many UNIQUE constraints on a table whereas we can have only one PRIMARY KEY.   Example of UNIQUE constraint on CREATE TABLE   < […]

SQL Clone Table

The SQL clone table may be used in a situation that you need an exact copy of a table and CREATE TABLE … SELECT doesn’t suit your purposes because the copy must include the same indexes, default values, and so forth. You can handle this situation by following steps: You can handle this situation by […]

SQL Having Clause

Having clause is used to mention condition in Group based SQL functions, just like WHERE clause .It acts as the same way as does where clause is used: Syntax for having will be, < View plain text > sql select column_name, function(column_name) FROM table_name WHERE column_name condition GROUP BY column_name HAVING function(column_name) condition   Example […]

SQL GROUP BY Statement

The SQL Group by statement is used to group the results of a SELECT query based on one or more columns.   The syntax for using Group by in a statement.   < View plain text > sql SELECT column_name, function(column_name) FROM table_name WHERE condition GROUP BY column_name   Example of Group by in a […]

SQL Distinct Keyword

The distinct keyword is mainly  used with the Select statement  in order to get  unique values from the desired table. Distinct removes all the redundant records while retrieving from the database.   Syntax for DISTINCT Keyword < View plain text > sql SELECT distinct column-name from table-name;   Example Consider the following consumer table. < View plain text > sql […]

SQL Temporary Tables

The temporary tables could be exceptionally valuable at times to keep transitory information. An essential thing that ought to be known for impermanent tables is that they will be erased when the present customer session ends.   Brief tables were included MySQL from 3.23. On the off chance that you utilize a more seasoned adaptation […]

SQL Primary Key Constraint

This constraint is used to uniquely define an identify any entry in the table. There are certain conditions like a primary key value can’t be NULL and it must be UNIQUE. There can be only one primary key in a table.   Example of PRIMARY KEY Constraint on CREATE TABLE   < View plain text […]

SQL Regular Expressions

Following is the table of pattern, which can be used along with REGEXP operator in a query for a selected table in the database. Pattern What the pattern is used /described for ^ Beginning of a given string \$ End of a given string . Any single character you wish to take […] Any character   that has […]