Operator in Sql Queries


SQL stands for Structured Query Language It can access and manipulate databases. It is an ANSI (American National Standards Institute) standard. Even Though SQL is an ANSI, there are many different versions of the SQL language. They all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner. Sql Server is a Relational Database Management System.It is stored in database objects called tables.A table consists of columns and rows.

Top Operator:



Using this Query you can fetch top records from table according to your need.. please find below Query

Example:



SELECT TOP number FROM table_name


LIKE Operator:



Like Operator is to search the specific pattern from a column

Example:



SELECT * FROM table_name WHERE column_name LIKE 's%'


IN Operator:



It can Specify multiple value in where clause

Example



SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)


BETWEEN Operator:



It Select the data at the range of two value

Example



SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2


Alias Operator:



We can use alias name for table or column


Example for Table



SELECT column_name(s) FROM table_name AS alias_name


Example for Column



SELECT column_name AS alias_name FROM table_name



SQL JOINS


Join keyword is used to combine the two table or more table. according to the relationship..

Different Types Of Joins


1)LEFT JOIN
2)RIGHT JOIN
3)FULL JOIN


Inner Join


The INNER JOIN return rows when there is least one match in both tables.

Example



SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.column_name

Left Join


It return all the row in left table even there is no matches in right table

Example




SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name


Right Join


It return all the table right table even there is no matches in left table

Example




SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name


Full Join


The FULL JOIN return rows when there is a match in one of the tables.

Example




SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: