You can use a DELETE statement with a subquery. The subquery would be used to select the records that do not have a parent code value and parent, and the DELETE statement would then remove those records from the table.

Example of how the SQL query would look:

DELETE FROM trade
WHERE NOT EXISTS (SELECT 1 FROM trade WHERE parent_code IS NOT NULL AND parent IS NOT NULL);
This query will delete all records from the "trade" table where the parent_code column is NULL and the parent column is NULL.

You can also use this query to delete records where the parent_code and parent value is empty

DELETE FROM trade
WHERE (parent_code ='' OR parent_code IS NULL) AND (parent ='' OR parent IS NULL);