How to copy information in SQL from one table to another

I need to build a query to copy information in a column from one table to a column in another table. This is how the tables looks like: People: PersonId Name StatusId 1 John 2 Jenny 3 Steve …

SQL Server Update Row where date is not the max date when records are grouped by some ID

I have a table where I account records are loaded daily. If an account comes in to the table and it already exists I keep both records in the database but need to update the record with older …

How to write the sql in SQLite with this?

WITH cteCountDownlines AS ( –=== Count each occurrence of EmployeeID in the sort path SELECT EmployeeID = CAST(SUBSTRING(h.SortPath,t.N,4) AS INT), NodeCount = COUNT(*) –Includes current …

Pgsql find similar records in database

I have a table that has the layout of this sensor_id time value 1 2020-12-22 09:00:00 20.5 1 2020-12-22 10:00:00 21.5 1 2020-12-22 11:00:00 22.5 1 2020-12-22 12:00:00 23.5 2 2020-12-22 09:00:00 …

Best way to restoring Audit table without existing primary keys – postgres

Table A has an audit table that I need to restore a specific column from. Rows were deleted from table A, I then regenerated them and via matching on specific times (these are appointment records) I’…

SQL Complex update query filter distinct values only

I have 3 tables with following columns. Table: A with column: newColumnTyp1, typ2 Table: B with column: typ2, tableC_id_fk Table: C with column: id, typ1 I wanted to update values in A.newColumnTyp1 …

After update trigger not updating specific row of data in SQL table

Fairly new to SQL here… I am trying to get an ‘after update’ trigger in SQL Server to update a column (rig_ident) whenever another column (rig_id) is updated. rig_ident is found by searching the …

How to insert yes or no value into flag column based on regex query

I have a simple update that works great work analyzing a US based telephone number. It correctly inserts a Y in the phone_flag column based on the following query. UPDATE database.table SET phone_flag …

Updating joint query in Oracle

I’m trying to update the name on the trade table according to the user table however as we have so many trades I don’t want my query to update each and every trade. only the ones that have the …

replace column with other column if value is ABC*

MYSQL PHPmyAdmin I have a table “photo” I have a column named “column_title” (varchar(300)) and a column named “column_description” (text). The title is sometimes ABC and …