SQL Related Questions answers
SQL Related Questions answers
1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators->and,or,not,between,any
Ans INNER JOIN (also known as a ‘simple’ JOIN). This is the most
common type of JOIN.
LEFT JOIN (or LEFT OUTER JOIN)
RIGHT JOIN (or RIGHT OUTER JOIN)
FULL JOIN (or FULL OUTER JOIN)
Self joins and cross joins
8) Write a query to count the number as Rows from two different tables?
Ans SELECT COUNT (distinct t1.id) + COUNT (distinct t2.id) AS
totalRows FROM firstTable t1, secondTable t2
9)Write a query to count the numbers of columns from two different tables?
Ans SELECT count(*) as No_of_Column FROM information_schema.columns
10)Write a query to get the date format dd-mm-yyyy?
Ans select to_char(yourdate,'DD/MM/YYYY' )
11) Write a query a name starts with “S” and end with “H”?
Ans select * from employees where ename like ‘s%h’
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
13)Differences between IN and BETWEEN operators
Ans Both of these operators are used to find out the multiple values from the table.
Differences between these operator is that the BETWEEN operator is used to
select a range of data between two values while The IN operator allows you to
specify multiple values.
14) Types of operators in SQL?
Ans Arithmetic operator
Comparison operator
Logical operator