INNER JOIN Operator :-INNER Join return all rows from the join of left table and right table if there are same data available in both tables if no data will match then it will return nullSELECT * FROM Table_Name_1 INNER JOIN Table_Name_2 WHERE Table_Name_1.Column_Name = Table_Name_2.Column_NameYou can divide your result in group like :- If a table...
SQL Tools(Alias Operator & In Operator)
ALIAS Name for Column :-SELECT Column_Name AS Alias_Name FROM Table_NameALIAS Name for table :-SELECT Column_Name From Table_Name AS Alias_NameALIAS Example :-SELECT p.FirstName,p.LastName, po.OrderIDFROM Persons AS p, Product AS poWHERE p.FirstName='Saurabh' AND p.LastName='Singh' AND po.OrderID > 2Without using AS SELECT p.FirstName,p.LastName,...
SQL - Tools (BETWEEN Operator)
SELECT column_name(s) FROM table_nameWHERE column_name BETWEEN value1 AND value2 SELECT * FROM COILS WHERE COIL_NAME BETWEEN SomeValue1 AND SomeValue2 Between operator is like It will select a row where COIL_NAME has SomeValue1 . Value depends on database to database . Some database will select rows where COIL_NAME has SomeValue1 and where COIL_NAME...
SQL - Tools(Top Clause AND Like Operator)
SELECT TOP 1 FROM Table_NameThis will select 1 row from tableSELECT TOP 1* FROM Table_Name (Select all columns of 1st row)SELECT TOP 2* FROM Table_Name (Select first two rows of table)SELECT TOP 50 PERCENT * FROM Table_Name (Select 50 % rows from table)LIKE OPERATORSELECT column_name(s)FROM table_nameWHERE column_name LIKE patternIF...
SQL - Tools ( INSERT,UPDATE and DELETE Statement)
INSERT INTO table_nameVALUES (value1, value2, value3,...)IF a table Persons contains P_Id,LastName,FirstName,Address,City columns.If you want to insert values then :-INSERT INTO PersonsVALUES (4,'Singh', 'Saurabh', 'Sector-23', 'Gurgaon')IF NOT EXISTS (SELECT * FROM Persons WHERE P_Id = 4)BEGININSERT INTO PersonsVALUES (4,'Singh', 'Saurabh', 'Sector-23',...
SQL - Tools(ORDER BY)
ORDER BY keyword is used for sorting suppose in a table there is a column named first_name.If you want to show the result in ascending order then :-SELECT * FROM Persons WHERE Age >= 25 GROUP BY first_name ASCIf you want to show the result in descending order then :-SELECT * FROM Persons WHERE Age >= 25 GROUP BY first_name DESCBy default it...
SQL - Tools (WHERE, AND, OR Clause)
Where clause is use for filtering like :-SELECT * FROM table_name WHERE column_name (operator) value(operator) :- =, >, <,! and more operators.A Friends table contains firstName, secondName, address, phone_no and firstName values are :- saurabh, sandy, gaurav, somu, saurabh and address column values are :- kanpur, allahabad, delhi, kanpur, varanasi.SELECT...
SQL - Tools....(SELECT Clause)
SELECT :-SELECT * FROM TABLE_NAME this will select whole table If Coils table contains 5 columns p_id, coil_no, coil_width, coil_length, coil_name.Then you have to select coil_width and coil_no like :-SELECT coil_width, coil_length FROM CoilsIf you have to select distinct columns from table like coil_name columns have ABCDE12, ABCD13, ABCD14, ABCD12,...