The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Hot answers tagged

2

Text values must be converted to numeric before any math operation. UPDATE schema.table SET ColumnA * ColumnC::numeric -- Use same data type as ColumnA Have a look at this tutorial


2

last part i want to get is either 3 or 4 characters. Ex: '1/2' or '1/12' UPDATE [TableName] SET [ColumnName] = LTRIM(RIGHT([ColumnName], 4))


2

if we were to update student relation wouldn't this be rejected This is correct. If there is no ON UPDATE action defined in the foreign key reference, your update of referenced key would coflict with the foreign key constaint so it would be rejected.


1

First cte unnest all elements of the array, second one update each element and then simply update the original table building the array again. with ct as ( select id, jsonb_array_elements(data) dt from t ) , ct2 as ( select id, jsonb_set(dt, '{updatedAt}', '"1571150000"', false) dt2 from ct ) update t set data = (select jsonb_agg(dt2) ...


1

There are a couple of options, depending on the state of your data. If the prefix is always 'aaa', then do this: UPDATE [TableName] SET [ColumnName] = LTRIM(RTRIM(REPLACE([ColumnName], 'aaa', ''))) If the prefix changes, but it is always the last 4 characters you want to retain, then do this: UPDATE [TableName] SET [ColumnName] = SUBSTRING([ColumnName], ...


1

UPDATE users SET isActive=0 FROM users JOIN userinfo ON users.id_emp = info.id_emp AND frdate IS NOT NULL ?


Only top voted, non community-wiki answers of a minimum length are eligible