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,...