Delete rows from Table, remove unpaid transaction

USMEDICAchannel

What to do if you want to delete rows?

Use UNNEST -

Error: Cannot access field hitId on a value with type ARRAY< STRUCT< hitId STRING, isEntrance INT64, isExit INT64, ...>>

delete
FROM
xxxx.session_streaming_20161029
WHERE 
h.hitId = (
SELECT hitId
FROM xxxx.session_streaming_20161029, UNNEST(hits) as h
WHERE h.transaction.transactionId = '123456')
Elliott Brossard

If I understand correctly, I think that you actually want:

delete FROM xxxx.session_streaming_20161029
WHERE EXISTS (
  SELECT 1
  FROM xxxx.session_streaming_20161029,
    UNNEST(hits) as h
  WHERE h.transaction.transactionId = '123456');

The idea is to match all rows where there is some transaction ID with value '123456'.

Edit: If the goal is to remove entries from hits with this transaction ID, and not to remove entire rows where hits contains the transaction ID, you can use UPDATE:

UPDATE xxxx.session_streaming_20161029
SET hits =
  ARRAY(SELECT hit FROM UNNEST(hits)
        WHERE transaction.transactionId = '123456');

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Delete rows from table

From Dev

Will delete from inside transaction remove records from after transaction

From Dev

Delete X rows from table

From Dev

Delete from table and remove file

From Dev

Delete duplicate rows from table with no unique key

From Dev

Better "delete rows from table" performance

From Dev

Delete Rows from a Constrained Reference Table

From Dev

delete rows from a table using MySQL Scheduler

From Dev

Delete rows from table recursively using JQ

From Dev

Delete duplicate rows from a BigQuery table

From Dev

Delete few rows from db table

From Dev

Cannot delete rows from a table SQL

From Dev

multiple queries to delete rows from table

From Dev

delete rows from a table that are not present in another

From Dev

How to delete some similar rows from a table?

From Dev

mysql delete duplicate rows from table

From Dev

Delete rows from table inner join

From Dev

SQL - Remove Duplicate Rows From Table

From Dev

SSRS Conditionally remove rows from a table

From Dev

Remove unnecessary rows from a relational table

From Dev

Remove unnecessary padding from table rows in CSS

From Dev

Jquery to remove all the rows from closest table

From Dev

Add & Remove Cells from Cloned Table Rows

From Dev

How to delete from table then delete what deleted rows referenced? (postgresql)

From Dev

How to Use Delete Triggers to Delete Rows From Same Table?

From Dev

Delete rows from a data table that exists in another data table

From Dev

Delete rows from a data table that exists in another data table

From Dev

How to delete rows from a table based on a join with another table?

From Dev

How to delete rows from one table matching another table?

Related Related

HotTag

Archive