3i Infotech Papers: Sample Questions 269 - 270 of 1245

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 269

» Database » MySQL

Essay Question▾

Describe in Detail

To retrieve information using SQL, what is the 1st word is your query?

Explanation

Explanation of SELECT statement.

Explanation of SELECT Statement.

Explanation of SELECT statement.

  • To retrieve information using SQL, SELECT is the 1st word is in query

SQL SELECT statement:

  • Starts with the SELECT keyword

  • Used to retrieve information from MySQL database tables.

  • Made of several different keywords known as clauses.

  • Query may retrieve information from specified columns or from all of the columns in the table.

  • To specify the column name and the table name, to create a simple SQL SELECT statement

  • The whole query is called SQL SELECT Statement.

Syntax of SQL SELECT Statement:

SELECT “column1”

[, “column2”, etc]

From “tablename”

[where “condition”];

[] = optional

Conditional selections used in the where clause:

= Equal

> Greater

< Less than

> = Greater than or equal

< = Less than or equal

< > Not equal to

Ex.

SELECT first_name + ’ ’ +

Last_name As emp_name FROM

Employee;

O/P

emp_name

Question number: 270

» Database » MySQL

Essay Question▾

Describe in Detail

What are the different types of JOIN operations?

Explanation

Below the types of joins

  • Inner Join

  • Outer join

    • Left outer join

    • Right outer join

    • Full join

  • Inner join

The INNER JOIN keyword selects records that have matching values in both tables.

Syntax of Inner join

SELECT column_name (s)

FROM table1

INNER JOIN table2 ON table1. column_name = table2. column_name;

  • Outer Join

Left Outer join:

Image of the Left Outer join

Image of the Left Outer Join

Image of the Left Outer join

  • The left outer join keyword returns all records from the left table (table1), and the matched records from the right table (table2).

  • The result is NULL from the right side, if there is no match.

    Syntax of left outer join

    SELECT column_name (s)

    FROM table1

    LEFT JOIN table2 ON table1. column_name = table2. column_name;

Right Outer join:

Image of the Right Outer join

Image of the Right Outer Join

Image of the Right Outer join

  • The right outer join keyword returns all records from the right table (table2), and the matched records from the left table (table1).

  • The result is NULL from the left side, when there is no match.

    Syntax of right outer join:

    SELECT column_name (s)

    FROM table1

    RIGHT JOIN table2 ON table1. column_name = table2. column_name;

Full Outer join:

Image of the Full Outer join

Image of the Full Outer Join

Image of the Full Outer join

  • The FULL OUTER JOIN keyword return all records when there is a match in either left (table1) or right (table2) table records.

    Full outer join syntax:

    SELECT column_name (s)

    FROM table1

    FULL OUTER JOIN table2 ON table1. column_name = table2. column_name;

  • Simple outer join is combination of left and right outerjoins.

  • Apart from these there are

  • Natural join: Cartisian product

  • Equi join: Which includes = operator in condition

  • NonEqui join: All conditional joins which do not use = in there conditions.