S.Jackson
S.Jackson

Reputation: 159

DELETE rows with condition inside a query in BigQuery

I am creating a new table with a select query in BigQuery and I want to be able to create without the rows where prd.univ is NULL.

My query is like follows:

 select
        prd.key_web
        , dat_log
        , prd.nrb_fp
        , prd.tps_fp
        , prd.univ
        , prd.suniv
        , prd.fam
        , prd.sfam
    from product as prd
    left join cart as cart
        on prd.key_web = cart.key_web
        and prd.dat_log = cart.dat_log
        and prd.univ = cart.univ
        and prd.suniv = cart.suniv
        and prd.fam = cart.fam
        and prd.sfam = cart.sfam

The aim here is to exclude the rows that have the value for the prd.univ as NULL from my resulting table in minimal steps.

Upvotes: 1

Views: 2540

Answers (2)

Gordon Linoff
Gordon Linoff

Reputation: 1271241

the LEFT JOIN makes no sense, because you are only fetching columns from the first table. Your filtering is then a WHERE clause:

select prd.key_web, prd.dat_log, prd.nrb_fp, prd.tps_fp,
       prd.univ, prd.suniv, prd.fam, prd.sfam
from product prd
where prd.univ is not null;

Upvotes: 3

Zaynul Abadin Tuhin
Zaynul Abadin Tuhin

Reputation: 32031

you need where condition

where prd.univ is not null

Upvotes: 3

Related Questions