Tutorials

SQL HAVING Clause

Submitted by admin on

The HAVING Clause is always used after the GROUP BY clause, it can not come without the GROUP BY clause. It works the same as the WHERE Clause, it is therefore also used to apply conditions on the aggregate_functions which was impossible by using simple WHERE clause.

The HAVING clause simply contains the conditions to filter data just like in WHERE clause.

SQL HAVING Syntax

SQL FOREIGN KEY Constraint

Submitted by admin on

A FOREIGN KEY is a key in another table that relates from the PRIMARY KEY in the parent table. A Foreign Key is needed in the related table to connect data from the primary table.

Let's take a look at the following example

Course Table

CourseID Course
1 Math 101
2 English 101

Students Table

SQL PRIMARY KEY Constraint

Submitted by admin on

Every table must be identified with a unique key or the Primary Key. Primary Key uniquely identifies each record in the table. It makes searching of record faster.
A Primary Key cannot contain a NULL values and must be unique in every record.

Different DBMS have different implementations to set the primary keys, so let’s see each of them below.

SQL PRIMARY KEY Syntax

SQL Create Database Statement

Submitted by admin on

Besides creating the database from the DBMS software like Oracle, MyQL, Microsoft Access etc. We can also create database with the query language. It is as simple as writing a SELECT, INSERT, UPDATE, DELETE Statement.

Creating a database using query language is very useful if for example you deploy your application to a computer that doesn’t have a database yet.

We can create a new database with the following syntax

SQL Create Database Syntax

SQL LEFT JOIN Keyword

Submitted by admin on

There are times when you want to retrieve all data from one table even there is no matching record from both tables. Unlike SQL INNER Join, SQL LEFT Join will still show you the result from the left table or the first table. SQL INNER Join as discussed in the previous chapter will only show records that match on both tables based on the column you specified.

How to Enable Remote Connection on SQL Server

Submitted by admin on

In this tutorial I will teach you on how to enable remote connection on SQL Server. I will use SQL Server 2005 Express Edition on this tutorial. However, this is also applicable to any version of SQL Server. The only difference is the GUI for different kinds of SQL Server version.

This tutorial is very useful if you want to access your SQL Server database from other computer and you want to connect two or more computers from your network.