IN vs ANY operator in PostgreSQL

(Strictly speaking, IN and ANY are Postgres “constructs” or “syntax elements”, rather than “operators”.) Logically, quoting the manual: IN is equivalent to = ANY. But there are two syntax variants of IN and two variants of ANY. Details: How to use ANY instead of IN in a WHERE clause? IN taking a set is equivalent … Read more

Oracle Differences between NVL and Coalesce

COALESCE is more modern function that is a part of ANSI-92 standard. NVL is Oracle specific, it was introduced in 80‘s before there were any standards. In case of two values, they are synonyms. However, they are implemented differently. NVL always evaluates both arguments, while COALESCE usually stops evaluation whenever it finds the first non-NULL … Read more

INSERT … ON DUPLICATE KEY (do nothing)

Yes, use INSERT … ON DUPLICATE KEY UPDATE id=id (it won’t trigger row update even though id is assigned to itself). If you don’t care about errors (conversion errors, foreign key errors) and autoincrement field exhaustion (it’s incremented even if the row is not inserted due to duplicate key), then use INSERT IGNORE like this: … Read more

How to create Temp table with SELECT * INTO tempTable FROM CTE Query

Sample DDL create table #Temp ( EventID int, EventTitle Varchar(50), EventStartDate DateTime, EventEndDate DatetIme, EventEnumDays int, EventStartTime Datetime, EventEndTime DateTime, EventRecurring Bit, EventType int ) ;WITH Calendar AS (SELECT /*…*/) Insert Into #Temp Select EventID, EventStartDate, EventEndDate, PlannedDate as [EventDates], Cast(PlannedDate As datetime) AS DT, Cast(EventStartTime As time) AS ST,Cast(EventEndTime As time) AS ET, EventTitle … Read more

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