I have a table - "cla_retail" - in sql that has 20,000+ rows. I have read the tables in R using dbConnect and stored it in a dataframe called "cla_retail_df" I am trying to execute a DELETE query using sqldf on dataframe abc. This delete query works fine when I execute it in mySQL but returns 0 results when I execute it in R.
I also tried using dplyr but I got confused with the many "not" in the sql query. I have initialised the other dataframes
- sales_vou_main_appr,
- issue_to_karigar_approval_main ,
- issue_to_hallmark_main ,
- sample_issue_to_karigar_main
Here is what I have tried in R and throws 0 rows in abc_v2:
abc <- cla_retail_df
abc_v2<- sqldf("delete from abc where status<>'N' and barcode not in(select barcode from sales_vou_main_appr where ret_status='0') and barcode not in(select barcode from issue_to_karigar_approval_main where ret_status='0') and barcode not in(select barcode from issue_to_hallmark_main where rec_status='0') and barcode not in(select barcode from sample_issue_to_karigar_main where rec_status='0')")
DELETEinstead ofUPDATE. The premise is (I believe) the same:sqldfdoesn't delete in-place, and it never returns automatically. If you wantabc_vwto be the contents ofcla_retail_dfwithout the rows, thenabc_v2 <- sqldf(c("delete from abc where ...", "select * from abc")).