Newby working on my first project. Sorry for this explanation. I have 2 x tables: t1: master table with single rows (unique project-id) and 3 status fields, s1,s2,s3 t2: list table with repeating project_id’s with 3 status fields s1,s2,s3 (and other data not relevant here). The value in the s1-3 fields is either true(1) or false(0) table1: project_id, status1, status2,
Tag: sql-update
Replace all email addresses after ‘@’ in PostgresSQL
I have a list of emails. I want to change all of them to test emails for my test system e.g. sam@gmail.com to sam@test.com. I don’t want to use actual emails as those emails are valid and it will be bad for users to receive such email. Is it possible to change all emails at once in a single query?
How to Update some records with still maintain other records in Codeignitter?
Table Info : id-data id-note note 1 5 I went home with John Harrison 2 5 I had dinner with John Harrison 3 5 I went shopping with John Harrison 4 3 I had dinner with John Harrison I want to update “John Harrison” in note where id-note (5), with “Sebastian” but still maintain the other sentence, using codeigniter-3 model-controller
How to update a table with a foreach without overwriting?
So i’m working on a university project but i have a problem that’s really starting to bother me. I am trying to update my database several times with different values, except that only the last value will be taken into account : they’re overwriting themselves. My code : And my SQL method is like this : So for example if
How to update USING sum and subquery
I have a SQL Server table similar to this: InkitemNo CapacityUnit NewInk OldInk ReturnInk ProdQty Description UsedInk 204 Machine1 5 2 0 4000 Next ? 223 machine2 4 3 1 8000 NULL ? 204 Machine2 0 0 0 5000 Next ? 224 Machine2 4 0 2 3000 Next ? I’m trying to write a query with this formula: Example to
Update and renew data based on data in other tables
There are 3 tables student, course, and takes as following tot_cred column data in the student table now is assigned with random values (not correct), I want to perform the query that updates and renews those data based on the course’s grade each student has taken. For those students who received F grade will be excluded and those who didn’t
Update a a column in some specific items of a table, with values from a column in another table
I have 3 tables. I want to update all Image rows from table 1, with local image from table 3. Table 1 is liked with table 2 by ID. Table 2 and 3 are linked by itemRef. As an example of what I want: is that ID 1 from table 1, gets image A. Because ID from table 1, is
Update to replace specific value with another except when it already exists
I have a table with values like this: There’s also a UNIQUE constraint on both columns I want to change all ‘poo’ to ‘woo’, as long as it doesn’t violate the constraint, and then delete the remaining ‘poo’, in order to obtain this table: My attempts to far for the first step: Result: UNIQUE constraint failed: [..] Result: [..] 0
Postgres giving relation does not exist error for alias
Above query is working fine in MS Sql but showing this error when running it in postgres Answer In MS Sql Server it’s possible to update the CTE. In Postgresql you can link to a CTE for an update. For example: However, such update assumes that the id in that table is unique. But, to mark the newest duplicates it
When I update the same row in a table in SQL more than once, it gives an ORA-00001: unique constraint error
I am trying to update a row in a table in SQL back to back and am getting an error when running the second update statement. I’m getting an error in the second update statement. ORA-00001: unique constraint (ADMIN.JHIST_EMP_ID_ST_DATE_PK) violated ORA-06512: at “ADMIN.ADD_JOB_HISTORY”, line 10 ORA-06512: at “ADMIN.UPDATE_JOB_HISTORY”, line 2 ORA-04088: error during execution of trigger ‘ADMIN.UPDATE_JOB_HISTORY’ I was expecting