How to delete data from list with check condition
Tag : chash , By : Igor Carron
Date : March 29 2020, 07:55 AM
it should still fix some issue You can use List.RemoveAll: List<boko_data_json> thedata = Newtonsoft.Json.JsonConvert.DeserializeObject<List<boko_data_json>>(json);
theData.RemoveAll(n => n.status == "0");
|
How to delete duplicate data with a condition
Tag : mysql , By : sgmichelsen
Date : March 29 2020, 07:55 AM
wish helps you Try this delete statement, it works as described in rules and gave correct output for your examples: SQLFiddledelete from tbl_test t
where t.sta in ('F', 'R') and exists (
select 1 from tbl_test b
where b.ser_no = t.ser_no
and (sta='L' or (sta<>'L' and b.id<t.id)) )
|
data.table: delete row following those matching specified condition?
Tag : r , By : user165781
Date : March 29 2020, 07:55 AM
will be helpful for those in need I'll write in data.table because I prefer the syntax; the translation to base is straightforward. library(xts) #Needed to get the following "xts" "zoo" object
data1 <- structure(c(6.32, 6.27, 6.3, 6.3, 6.26, 6.24, 6.36, 6.36, 6.3,
6.36, 6.28, 6.5, 6.21, 6.22, 6.3, 6.23, 6.2, 6.24, 6.22, 6.3,
6.3, 6.23, 6.24, 6.44, 329400, 126500, 0, 126600, 54000, 61000,
6.22, 6.3, 6.3, 6.23, 6.24, 6.44), .Dim = c(6L, 6L), .Dimnames = list(
NULL, c("open", "high", "low", "close", "volume", "adj.")), index = structure(c(1387756800,
1387843200, 1387929600, 1388016000, 1388102400, 1388361600), tzone = "UTC", tclass = "Date"), .indexCLASS = "Date", tclass = "Date", .indexTZ = "UTC", tzone = "UTC", class = c("xts",
"zoo"))
library(data.table)
#setDT fails on "xts" "zoo" object. We need as.data.table
#setDT(data1) #convert to native 'data.table' class _by reference_
data1 <- as.data.table(data1)
data1[if (!length(rows <- -c(idx <- which(volume == 0), (if (volume[.N] == 0) idx[-length(idx)] else idx) + 1L))) TRUE else rows]
data1[if (!length(rows <- -c(idx <- which(volume == 0), idx + 1L))) TRUE else rows]
|
dblink_build_sql_delete . I need to be able to delete the data with <= condition
Date : March 29 2020, 07:55 AM
I hope this helps . , why not just dblink and format?.. t=# create table so43 (i int);
CREATE TABLE
t=# insert into so43 select 1;
INSERT 0 1
t=# select * from dblink('dbname = t',format('delete from so43 where i <= %s',1)) as row(result text);
result
----------
DELETE 1
(1 row)
|
I want to delete data on condition.if data is available in another table as a foreign key then donot delete this
Date : March 29 2020, 07:55 AM
seems to work fine i have 3 tables, 1 is for bloggers, blogger id is save in the campaign table as a foreign key and also save in the categories tables as a foreign key which is the junction table actually. , you need change in delete function just like this function delete($id){
$result = $this->db->query("SELECT blogger_id FROM tbl_campaign_detail WHERE blogger_id = $id")->row();
if(!$result){
$this->db->query("DELETE FROM tbl_bloggers_cat WHERE blogger_id = $id AND Cat_id > 2000");
if($this->db->affected_rows() > 0){
return true;
}
}
return false;
}
|