Tutor profile: Kalai D.
Subject: SQL Programming
Correct usage of WHERE and HAVING clause also explain GROUP BY
Both WHERE and HAVING clauses are used for restricting the values based on a specific condition. WHERE is generally used with conditions involving single row functions. Ex. where salary<100000 or round(comm)>500 HAVING is used with conditions involving multiple row functions. Ex. HAVING max(salary)<100000 GROUP BY clause is used along with any aggregate functions. Ex. Select max(salary) from emp group by designation - Here it lists out max salary of each designation Note:- GROUP BY cannot appear without aggregate function (at least one) But it is not mandatory to have GROUP BY clause when the query contains Group functions (i.e aggregate functions) It appears in the order WGH - where , group by , having ( may be student can remember with their own example like Where is Girls' Hostel or Where is Government Hospital
Subject: Information Technology
Steps to connect JDBC driver with Database:-
JDBC - Java Database Connectivity is developed by Sun Java (which is now acquired by Oracle) for connecting Java App with different Back ends like MySQl, Oracle and so on. 1. Import the necessary packages import java.sql.* (* indicates Connection, DriverManager, Statement and ResultSet here) 2. Register the JDBC driver with Driver Manager Class.forName("java.sql.Driver") 3.Set up a connection Connection con = DriverManager.getConnection(path along with local host, username, password); path can be "jdbc:mysql://localhost:3306/Databasename" 4. Create a statement Statement stmt = con.CreateStatement() 5.Execute a query Select - ResultSet rs = stmt.executeQuery( "select query") update,delete and insert - int i = stmt.executeUpdate("sql statement")
Difference between Count(ColumnName) and Count(*) function with respect to NULL Values
Actually Count is a Aggregate function and all the aggregate function generally omits NULL value and process on the remaining records. Count(ColumnName) also works in similar way by avoiding NULL values. But Count(*) includes NULL values as * which just indicates a mere selection of any values. Let us see with an example. Assume ID column as Non- Primary Key Emp - Table ID Name 1 X 2 Y 3 NULL NULL NULL Now Count(Name) will result in 2 Count(ID) will result in 3 and Count(*) will result in 4
needs and KALAI will reply soon.