Monday, 24 August 2015

Write a query to diplay product name whose assign many employee in product table.

Table Name: Emp

EmpIdName
1Sagar
2Raj
3Mohan
4Anand
5Tiku

Table Name:  Product

ProductIdEmpIdProductName
11Product1
21Product2
32Product3
43Product4
55Product5
63Product6

select pp.proname,pp.proid,pp.empid from
(
select t.aaa,empid from
(
select count(proid)as aaa,empid  from product as p group by p.empid
) as t where t.aaa >= 2
) as t2 left join product as pp on t2.empid = pp.empid

Write a query to display employee name whose not assign any product table.

Table Name: Emp

EmpIdName
1Sagar
2Raj
3Mohan
4Anand
5Tiku

Table Name:  Product

ProductIdEmpIdProductName
11Product1
21Product2
32Product3
43Product4
55Product5



SELECT Empid, name FROM Emp e
WHERE NOT EXISTS
(
         SELECT * FROM Product AS p WHERE p.empid = e.empid
)

How to find second highest salary in SQL using TOP?


Table Name : SalaryDetails

IDSalary
11000
2500
3750
4500
5350
6750

SELECT TOP 1 salary FROM
(
             SELECT DISTINCT TOP 2 salary FROM SalaryDetails ORDER BY salary DESC
) a
ORDER BY salary asc

Wednesday, 19 August 2015

Difference between get and post method.


GET (HTTP)

POST (HTTP)

HistoryParameters remain in browser history because they are part of the URLParameters are not saved in browser history.
BookmarkedCan be bookmarked.Can not be bookmarked.
BACK button/re-submit behaviourGET requests are re-executed but may not be re-submitted to server if the HTML is stored in the browser cache.The browser usually alerts the user that data will need to be re-submitted.
Encoding type (enctype attribute)application/x-www-form-urlencodedmultipart/form-data or application/x-www-form-urlencoded Use multipart encoding for binary data.
Parameterscan send but the parameter data is limited to what we can stuff into the request line (URL). Safest to use less than 2K of parameters, some servers handle up to 64KCan send parameters, including uploading files, to the server.
HackedEasier to hack for script kiddiesMore difficult to hack
Restrictions on form data typeYes, only ASCII characters allowed.No restrictions. Binary data is also allowed.
SecurityGET is less secure compared to POST because data sent is part of the URL. So it's saved in browser history and server logs in plaintext.POST is a little safer than GET because the parameters are not stored in browser history or inweb server logs.
Restrictions on form data lengthYes, since form data is in the URL and URL length is restricted. A safe URL length limit is often 2048 characters but varies by browser and web server.No restrictions
UsabilityGET method should not be used when sending passwords or other sensitive information.POST method used when sending passwords or other sensitive information.
VisibilityGET method is visible to everyone (it will be displayed in the browser's address bar) and has limits on the amount of information to send.POST method variables are not displayed in the URL.
CachedCan be cachedNot cached