w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Updating parentID in child table and deleting duplicate rows from parent table
I would do this in three steps. You didn't specify your RDBMS type, so this is pretty generic syntax. Create a mapping table for the new location_id: create table new_loc_map as select a.id_location as old_loc a.city , b.id_location from location a join ( select city , min(id_location) as id_location from location group by city ) b on a.city=b.city Update the location_geo table: update location_geo from new_loc_map set location_geo.id_location=new_loc_map.id_location where location_geo.id_location=new_loc_map.old_loc Create a new location table: create table new_location as (select distinct id_location , city from new_loc_map ) unique index idx (location) Your question describes creating a new composite index on your location table to remo

Categories : Mysql

mysql update rows in table after one of them is deleted
Usually this is done application-side as a subsequent update: DELETE FROM guide_steps WHERE id=? UPDATE guide_steps SET stepOrder=stepOrder-1 WHERE stepOrder>? AND projectid=? You can lock this inside a transaction to avoid one step being done without the other. It's also possible to wrap this up in a trigger, but that's usually a bad idea as it can be complicated to maintain those, and it's easy to get "trigger happy".

Categories : Mysql

Deleting dynamically created table rows
you are binding event when row clicked $('#newbook input[type="button"]').click(function () { $(this).closest('tr').remove(); }); this should at the end of your code and remove the binding event with element.onclick

Categories : Javascript

Issue with Deleting rows from my second Table in my page
You shouldn't mix the delete's because you might have an instance when one id be the same as the other, so you'll delete the wrong thing. But I don't believe that is your primary problem: Your select is SELECT ID2, Klant, Categorie1, SerieNummer1, MacAdress1, ProductCode1, Prijs1, Hoeveelheid1, Aantekeningen1 FROM CDE But your delete is: DELETE FROM CDE WHERE id = ?"; You're delete should probably be: DELETE FROM CDE WHERE ID2 = ?"; To Prevent Deleting the wrong thing: The easiest thing to do here, is change you're delete user JavaScript to accept an action parameter and specify which delete you want to perform, because both delete attempts are running right now. JavaScript You don't need the JavaScript twice on the same page. Just have it one time in your HEAD or right befo

Categories : PHP

SQLDF Left Join still deleting rows from Table A
Can you try the following sql query? SELECT TimeSeries.StartYear, TimeSeries.StartMonthNo, CommonName, EstimatedBiomassg, ScaledProportionofDominantNektonBiomass FROM TimeSeries LEFT JOIN TrawlBiomassbyMonth ON TimeSeries.StartYear = TrawlBiomassbyMonth.StartYear AND TimeSeries.StartMonthNo = TrawlBiomassbyMonth.StartMonthNo WHERE CommonName = 'White shrimp' AND RegionCode = 1") From reading your post, the issue is there are some NULL fields in the right hand table, and you wish to include all rows from the left hand table even when there is no match? Could you possibly setup a http://sqlfiddle.com/ ? PS due to my stackoverflow rep I was unable to comment, so although this isnt an answer, I'm trying to help

Categories : SQL

Why the Item deleted from an array but isn't deleted from my table?
You're not returning the table after you delete the item. When you call the method to delete it and write out the table, that table is not returned after you remake the table. Take this: JScrollPane loginsScrollPane = new JScrollPane(loginsTable); Bring it outside of your method. What I think might be happening is when you create your loginsScrollPane locally inside the method, it's not being added properly to your testPanel. I think what might be happening is when you add it, and the method ends it's loosing that data that is contained. Declare your scrollpane, and your jtable where you declare your frame.

Categories : Java

Can JPA handle deleting a parent object when the child is deleted?
When you delete an object in JPA, you must first remove all references to it form your model. If you want to delete an Employee, first remove the Employee from all Views. For the address if you use @CascadeOnDelete, ensure you have set the constraint to cascade, otherwise remove this.

Categories : Java

Deleting a child node stops other siblings from being deleted?
getElementsByClassName returns a live NodeList. So while you remove an element from the DOM it is also removed from the NodeList, causing various side effects. You can avoid them by converting the NodeList to an Array var Messages = [].slice.call(document.getElementById('LoginFormErrorWrapper').getElementsByClassName("FormErrorMessage"));

Categories : Javascript

Deleting first node in linked list after the rest has be deleted
So the problem is in the line if (previous == null){previous = current;} First three items are 4. On remove(4), steps followed are first = first.next //First points to 2nd item 4 but current still points to first item 4. if(current.item == item) current = current.next //Now current also points to second 4. previous = current // Since previous is null, so if statement will be true, previous also point to second 4. In furthur while loops, previous is not null and you are assigning current to previous.next. So you never skipped second 4. UPDATE: Say you have a node head pointing to a dummy node following by other nodes. remove(item) { previous = head; current = head.next; while(current!=null) { if(current.item == item) { previous.next = curren

Categories : Algorithm

Deleted rows with a specified string (MatLab)
You are using strcmp(), which compares the equality of two strings. That is not what you are after; you want to check whether some string is a substring of another string. You can use strfind or findstr or regexp or regexprep for that purpose. ALso, you are not closing your text file. This can lead to all sorts of problems. Make it a habit to always write fid = fopen(...); fclose(fid); as if it is one command, and then continue coding in between. A small example: fid = fopen('text.txt'); tttt = textscan(fid, '%s %s','delimiter',' '); tttt{2}(~cellfun('isempty', strfind(tttt{2}, 'omit'))) = []; fclose(fid); EDIT: based on your comments, I think you want to do this: fid = fopen('text.txt'); % Modified importcommand tttt = textscan(fid, '%s%s',... 'delimiter',' ',....

Categories : Matlab

core data do all relation objects get deleted too when deleting an entity's objects
That depends on what settings you have configured. For each relationship you can set it to: Do nothing Cascade (delete the other item too) Nullify Deny (don't allow the deletion) You specify this for each relationship in the model (and both ends of each relationship).

Categories : IOS

Keeping a reference to deleted rows in UITableView
When you place the same object in two arrays, the objects are not duplicated, they are simply referenced twice. So, the second is the correct way in most cases. If the goal of your filter is a search, for example, you can create the first array, and then the second using a filter with predicate to speed up the creation process. For example, you have an array of objects (in this example: array of activities) and want to show only the activities that contains "programming" NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(activityName CONTAINS[cd] %@)", @"programming"]; // activityName is the @property that you want to apply the filter to NSMutableArray *arrayToShow = [[firstArray filteredArrayUsingPredicate:predicate] mutableCopy];

Categories : IOS

Select rows in one table, adding column where MAX(Date) of rows in other, related table
If we assume that tasks only become more complete, you can do this with a left outer join and aggregation: select t.ID, t.Name, coalesce(max(n.complete), 0) from tasks t left outer join notes n on t.id = n.id_task group by t.id, t.name If tasks can become "less complete" then you want the one with the last date. For this, you can use row_number(): select t.ID, t.Name, coalesce(n.complete, 0) from tasks t left outer join (select n.*, row_number() over (partition by id_task order by date desc) as seqnum from notes n ) n on t.id = n.id_task and n.seqnum = 1; In this case, you don't need a group by, because the seqnum = 1 performs the same role.

Categories : SQL

How to insert records from multiple rows in a table into single rows (group my ID) in other table?
Try the following statement: CREATE TABLE new_table AS SELECT name1.id , name1.name AS name1 , name1.fullname AS fullname1 , name2.name AS name2 , name2.fullname AS fullname2 , name3.name AS name3 , name3.fullname AS fullname3 FROM ( SELECT * FROM ( SELECT id, name, fullname , rank() over ( partition by id order by fullname asc) as rank FROM old_table ) WHERE rank = 1) name1 , ( SELECT * FROM ( SELECT id, name, fullname , rank() over ( partition by id order by fullname asc) as rank FROM old_table ) WHERE rank = 2) name2 , ( SELECT * FROM ( SELECT id, name, fullname , rank() over ( pa

Categories : Oracle

How to delete all child rows when parent will deleted? Hibernate
The problem probably is that the relation is defined in the wrong direction. Presuming that you have an account table with one-to-many relation to a mail table, you will end up not being able to delete a record from account until it has associated mail rows if you define the relation on account to reference mail. The correct way is to create the foreign key on mail to reference account. With ON DELETE CASCADE, you tell MySQL that it should delete a row (whose table has the foreign key) if its parent (referenced by the key) is deleted. This operation is allowed by definition because in such a case the deleted record has references to it. In contrast, a deletion is not allowed if a record has references pointing to other records from it.

Categories : Java

Select from a table and insert to another table and deleting it from the source table
Have a look at: MySQL Trigger - delete after update What you want is to trigger a delete after your insert. DELIMITER $$ CREATE TRIGGER trigger1 AFTER INSERT ON tbl_friends FOR EACH ROW BEGIN DELETE FROM tbl_requests WHERE ID = new.id; END $$

Categories : Mysql

Use Invoke-SQLCmd and return number of rows deleted/affected
You could call the ROWCOUNT function feature in SQL immediately after your query to do the following: Select @@ROWCOUNT More information on ROWCOUNT @ http://technet.microsoft.com/en-us/library/ms187316(v=sql.90).aspx In addition, you could take a row count before the deletion of records and do another row count after deletion then do the difference. This will only work on inserted/deleted records and will not work on for records that are updated. SELECT COUNT( my_table.my_col ) AS row_count

Categories : Sql Server

Move deleted data from a table to another table
If the table does not participate in foreign keys, have triggers, have an identity column, computed columns, etc. you may be able to do something like this with the OUTPUT clause: DELETE dbo.Table1 OUTPUT deleted.* INTO dbo.Table2 WHERE ... You can work around some of these limitations by writing a more creative OUTPUT clause, but not all of them. If you have any restrictions that prevent the use of the OUTPUT clause, you could use an INSTEAD OF trigger to perform both operations. CREATE TRIGGER dbo.TriggerOnTable1 ON dbo.Table1 INSTEAD OF DELETE AS BEGIN SET NOCOUNT ON; INSERT dbo.Table2(cols) SELECT cols FROM deleted; DELETE t FROM dbo.Table1 AS t INNER JOIN deleted AS d ON t.key_column = d.key_column; END GO A lot of people question the value of INSTEAD OF tri

Categories : Sql Server

I have two table called Event table and Date table.I want to show following display table without duplicating rows using sql
Try this: For MySQL SELECT EVENT_NAME, REPLACE(REPLACE(DATE_FORMAT(START_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.') START_DATE, CONCAT(REPLACE(REPLACE(DATE_FORMAT(START_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.'), ' - ', REPLACE(REPLACE(DATE_FORMAT(END_DATE, '%Y/%m/%d %h:%i:%s %p'), 'AM', 'a.m.'), 'PM', 'p.m.')) FROM_TO FROM (SELECT ET.EVENT_NAME, MIN(STR_TO_DATE(REPLACE(ET.START_DATE, '.', ''), '%Y/%m/%d %h:%i:%s %p')) START_DATE, MAX(STR_TO_DATE(REPLACE(ET.START_DATE, '.', ''), '%Y/%m/%d %h:%i:%s %p')) END_DATE FROM EVENT_TABLE ET INNER JOIN DATE_TABLE DT ON ET.E_ID = DT.E_ID GROUP BY ET.E_ID ) AS A;

Categories : Mysql

List of deleting rows in datagridview
Use dataGridView1.SelectedRows to get a collection (DataGridViewRowCollection type) that contains all the rows selected. Same works for columns (dataGridView1.SelectedColumns) and cells (dataGridView1.SelectedCells). http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectedrows.aspx

Categories : C#

faster and efficient way of deleting rows
Auto filter is fast - definitely the way to go - but it hides data rows and doesn't delete them. Since your code turns the filter off at the end, the hidden rows come back. Instead, you should apply the filter, select all, copy, paste into new sheet, and delete the old sheet. This will be very fast - and do exactly what you are asking for. Apologies that I am not posting working code - typing on ipad...

Categories : Excel

deleting multiple rows via checkbox
PHP is automatically converting your checkboxes' POST value to an array, due to the fact that you are using array notation in the name attribute. Try something like this: $ids = implode( ',', $id ); $stmt = $mydb->prepare("update messages SET deleted ='yes' where to_user = ? and id IN(?) "); $stmt->bind_param('ss', $user, $ids); It's not clear from your code where $user is coming from.

Categories : PHP

Deleting rows with specific rules
I just tried the following codes on my desktop and it seems to do the trick. I made a as the cell array you had. L = size(a, 1); mask = false(L, 1); for ii = 1:L if isnumeric(a{ii, 1}) && (a{ii, 1} == 137 || a{ii, 1} == 2) mask(ii) = true; elseif ~isempty(a{ii, 3}) && strcmp(a{ii, 3}(end-1:end), ':T') mask(ii) = true; end end b = a(~mask, :) Now, b should be the cell array you wanted. Basically, I created a logical mask that indicates the position of rows that satisfy the rules, then use the inverse of it to call out the rows.

Categories : Matlab

Deleting Multiple Rows in a Matrix
Instead of deleting them after, just don't load them to start with. You can also short cut re-reading the file twice, as it appears you have a column limit of 9 set, so for each row, just pad it out with 0's to that size.... eg: import csv from itertools import chain, islice, repeat COLS = 9 # or pre-scan file to get max columns FILL_VALUE = 0 # or None, or blank for instance with open(filename) as fin: csvin = csv.reader(fin) # use appropriate delimiter/dialect settings non_blanks = (row for row in csvin if row[0]) # filter out rows with blank 1st col matrix = [list(islice(chain(row, repeat(FILL_VALUE)), COLS)) for row in non_blanks] Depending what you're doing with the data, you may also wish to look at the numpy module and the available loadtxt() method.

Categories : Python

Deleting Rows in VBA if it satisfies some criteria
Try this. Sub DeleteRows() Dim flag As Range, exitFlags As Range Set exitFlags = Selection //NOTE: just select the ExitFlags column For Each flag In exitFlags If flag = 1 Then flag.EntireRow.Delete Shift:=xlUp End If Next End Sub

Categories : Excel

Deleting certain rows from a data frame
It sounds like you actually want to split your dataframe, not delete rows from it. If the dataframes are of equal sizes and you want the three extracted dataframes to be random samples, specify something like: split(df, sample(1:3,dim(df)[1],TRUE)) to get a list of the three sampled, mutually exclusive dataframes. No need to delete anything from the original dataframe. Also, if you want to have the dataframes have different sizes, you can specify a prob argument in sample.

Categories : R

Issue when deleting rows from my database using html, php, js
I don't think this will work $sql="DELETE FROM BCD WHERE id='$Categorie', '$SerieNummer', '$MacAdress', '$ProductCode', '$Prijs', '$RekNummer','$PaletNummer' ,'$Hoeveelheid', '$Aantekeningen'"; You should separate the parameters with AND or OR, depending on what your successful delete criteria needs not a comma, also provide the column name each time. Something like $sql="DELETE FROM BCD WHERE id='$Categorie' AND serial_number='$SerieNummer', //etc It would be better to delete based on a primary key rather than such a range of values Also do not use mysql_ functions, use mysqli or PDO with parameterised queries

Categories : PHP

MongoDB not deleting rows, no error using c# driver
Found out what was causing this eventually! Like all good issues, this one was caused by me, as my dependency injection configuration was all set up correctly, and was pointing to the correct collection, however in the test rather than pointing to the "Entries" collection it was pointing to "Entry". It didn't click, even when I was using the GUI to check the table values, and the queries being sent seemed fine. Anyway there is no issues around searching using GUIDs etc, it was a red herring, so at least the problem is now solved, I hope this helps anyone else who is being an idiot like myself :)

Categories : C#

R: Conditional deleting rows and columns in a matrix
Here is a vectorized approach: i <- as.vector(row(m)) j <- as.vector(col(m)) k <- matrix(m == m[cbind(i, i)] & m < m[cbind(j, j)], nrow(m)) # [,1] [,2] [,3] [,4] [,5] [,6] [,7] # [1,] FALSE TRUE TRUE TRUE FALSE FALSE FALSE # [2,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE # [3,] FALSE FALSE FALSE TRUE FALSE FALSE FALSE # [4,] FALSE FALSE FALSE FALSE FALSE FALSE FALSE # [5,] FALSE TRUE FALSE FALSE FALSE FALSE FALSE # [6,] FALSE FALSE TRUE TRUE FALSE FALSE FALSE # [7,] FALSE TRUE FALSE FALSE FALSE FALSE FALSE delete.idx <- sort(unique(i[k])) # [1] 1 3 5 6 7 keep.idx <- setdiff(seq_len(nrow(m)), delete.idx) # [1] 2 4 m[keep.idx, keep.idx] # [,1] [,2] # [1,] 373 204 # [2,] 204 239

Categories : R

Error deleting rows in entity framework
By the call of context.xticketitem.Select(p => p.TicketID == ticketID); you will get a list of booleans that do not exist in context. I think you should do something like this: var ticketitem = context.xticketitem.Where(p => p.TicketID == ticketID); ticketItem.ToList().ForEach(r => context.xticketitem.DeleteObject(r)); context.SaveChanges(); EDIT: I've moved .ToList() on the next line to make differences between our snippets more evident. Let's try revise it step by step: When you call var ticketitem = context.xticketitem.Select(p => p.TicketID == ticketID); You are creating query that will go by all xticketitems and return whether each item's TicketID equals ticketID variable passed as an argument to your Delete method. Result of this query is IEnumerable<bool>.

Categories : Entity Framework

Deleting multiple rows from database by checkboxes
Javascript Since you are using jquery there is better way :) <script type="text/javascript"> var is_activate = true; // we will track which input button was clicked :) jQuery(function($) { $("#form input#check_all").change(function() { var inputs = $("#form input[type='checkbox']"); if ( $(this).is(":checked") ) { inputs.prop( "checked", true ); // inputs.attr( "checked", true ); // if its not working } else { inputs.removeAttr( "checked" ); } }); // Track clicked button $("#form input[type=submit]").on("click",function(e) { is_activate = ( $(this).hasClass("activate_btn") ) ? true : false; }); $("#form").submit(function(e) { e.preventDefault(); var string = ( is_activate ) ? 'ac

Categories : PHP

COUNT(*) takes long even after deleting all rows
After DELETE FROM Sdata try using OPTIMIZE TABLE Sdata to really discard the unused rows, or in the future, use TRUNCATE Sdata which will do this automatically for you. Quote from here: In MyISAM tables, deleted rows are maintained in a linked list and subsequent INSERT operations reuse old row positions. To reclaim unused space and reduce file sizes, use the OPTIMIZE TABLE statement or the myisamchk utility to reorganize tables.

Categories : Mysql

Deleting multiple rows based on row number(s)
This expression does not do what you think it does: WHERE RN IN (@RowNum) It is looking for cases where @RowNum is '1,2'. And this causes the problem, because '1,2' cannot be converted to an integer. You have declared the parameter an integer when you define the procedure, but then call it with a string. You can do what you want with: WHERE ','+@RowNum+',' like '%,'+RN+',%' The extra commas ensure that "1" doesn't match "10". EDIT: There are essentially three approaches (that I can think of) for handling a string of comma delimited integers as real integers (which is better because the query will use integers). One is to use the split() function, which returns a table of the elements of a delimited string. You can google for various implementations of it. The second is to us

Categories : C#

Deleting Rows meeting certain criteria in excel using vba (autofilter)
Each AutoFilter statement overrides the previous one, so in the end, your code only deletes all rows with Sick Accrued in column B -- try adding the delete statement between each Autofilter: With rngTable .AutoFilter Field:=ColumntoFilter1, Criteria1:=FilterCriteria1 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFilter2, Criteria1:=FilterCriteria2 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFilter3, Criteria1:=FilterCriteria3 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFilter4, Criteria1:=FilterCriteria4 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFilter5, Criteria1:=FilterCriteria5 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFilter6, Criteria1:=FilterCriteria6 .Offset(1, 0).EntireRow.Delete .AutoFilter Field:=ColumntoFi

Categories : Vba

Innodb memcached plugin in RDS not deleting expired rows
I'm by no means an expert, as I've just started to play around with memcached myself. However, this is from the MySQL documentation for the python tutorial. It seems to be saying that if you use the InnoDB memcached plugin, MySQL will handle cache expiration, and it really doesn't matter what you enter for the cache expire time. And for the flags, expire, and CAS values, we specify corresponding columns based on the settings from the sample table demo.test. These values are typically not significant in applications using the InnoDB memcached plugin, because MySQL keeps the data synchronized and there is no need to worry about data expiring or being stale.

Categories : Mysql

Make sure whether row in a table is deleted
Try reading the fine manual echo $this->connection->mysqli_conn->affected_rows;

Categories : PHP

Deleting a row in Table X based on the existence of a value in Table Y
It's hard to give a definitive answer without a bit more context. However, from an initial look at your code, assuming that it needs to adhere to standard SQL syntax, the following line would need updating from option_value FROM wp_options LIKE '%domain.com%' to WHEN EXISTS(SELECT 1 FROM wp_options WHERE option_value LIKE '%domain.com%') Hope that helps!

Categories : SQL

Locating specific values within cells and deleting identified rows
Sub Remove_Expendables() Dim c as range, rngDel as range set c= activesheet.cells(rows.count, "AA").end(xlup) Application.ScreenUpdating = FALSE Do While c.row > 1 If c.value like "L-*" Then if rngDel is nothing then set rngDel=c else set rngDel=application.union(rngDel,c) end if end if set c=c.offset(-1,0) Loop if not rngDel is nothing then rngDel.entirerow.delete Application.ScreenUpdating = TRUE End Sub

Categories : String

Deleting rows and columns in matrix based on values in diagonal in R
Use the diag function and logical comparison with < and the [ subset operator like this... idx <- ! diag(m) < 5 m <- m[ idx , idx ] e.g. m # x1 x2 x3 x4 #x1 13 15 12 25 #x2 23 4 23 34 #x3 21 11 1 11 #x4 11 22 23 33 idx <- ! diag(m) < 5 m <- m[ idx , idx ] m # x1 x4 #x1 13 25 #x4 11 33

Categories : R

When inserting and deleting rows in a tableView, how do I prevent it trying to add them at invalid locations?
Well, if there will only be two cells you don't need to make this overly complex. What I would do is use heightForRowAtIndexPath: and begin/end updates to do the heavy lifting for me. First, set up your each of your cells to display the username/password label/textfield/whatever you want on their top half, and the "details" on the bottom half. Then just modify heightForRowAtIndexPath: to by default return a value that will only expose the top half of the cell and only conditionally be large enough to reveal the entire cell. From there all you have to do is a little indexPath comparison and you're golden. - (void)viewDidLoad { [super viewDidLoad]; self.currentIndexPath = [NSIndexPath indexPathForRow:NSIntegerMax inSection:0]; } - (CGFloat)tableView:(UITableView *)tableView he

Categories : IOS



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.