CROSS JOIN vs INNER JOIN in SQL

Here is the best example of Cross Join and Inner Join. Consider the following tables TABLE : Teacher x————————x | TchrId | TeacherName | x———-|————-x | T1 | Mary | | T2 | Jim | x————————x TABLE : Student x————————————–x | StudId | TchrId | StudentName | x———-|————-|————-x | S1 | T1 | Vineeth | … Read more

Count work days between two dates

For workdays, Monday to Friday, you can do it with a single SELECT, like this: DECLARE @StartDate DATETIME DECLARE @EndDate DATETIME SET @StartDate=”2008/10/01″ SET @EndDate=”2008/10/31″ SELECT (DATEDIFF(dd, @StartDate, @EndDate) + 1) -(DATEDIFF(wk, @StartDate, @EndDate) * 2) -(CASE WHEN DATENAME(dw, @StartDate) = ‘Sunday’ THEN 1 ELSE 0 END) -(CASE WHEN DATENAME(dw, @EndDate) = ‘Saturday’ THEN 1 … Read more

Storing money in a decimal column – what precision and scale? [closed]

If you are looking for a one-size-fits-all, I’d suggest DECIMAL(19, 4) is a popular choice (a quick Google bears this out). I think this originates from the old VBA/Access/Jet Currency data type, being the first fixed point decimal type in the language; Decimal only came in ‘version 1.0’ style (i.e. not fully implemented) in VB6/VBA6/Jet … Read more

How to execute IN() SQL queries with Spring’s JDBCTemplate effectively?

You want a parameter source: Set<Integer> ids = …; MapSqlParameterSource parameters = new MapSqlParameterSource(); parameters.addValue(“ids”, ids); List<Foo> foo = getJdbcTemplate().query(“SELECT * FROM foo WHERE a IN (:ids)”, parameters, getRowMapper()); This only works if getJdbcTemplate() returns an instance of type NamedParameterJdbcTemplate

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)