Database-MySQL [3i Infotech Placement]: Sample Questions 33 - 34 of 162

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 33

Edit

Describe in Detail

Essay▾

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

Explanation

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 34

Edit

Describe in Detail

Essay▾

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:

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:

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:

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.

Developed by: