Delete a Single Row from a MySQL Table

Akshaya Akki
Updated on 20-Jun-2020 07:31:48

422 Views

We can use DELETE statement along with a WHERE clause, which identifies that particular row, to delete a row from MySQL table.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 4    | Aarav     | | 5    | Ram       | +------+-----------+ 5 rows in set (0.00 sec) mysql> DELETE from names where id = 4; Query OK, 1 row affected (0.07 sec)The query above will delete a single row having id = 4 from table ‘names’.mysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 5    | Ram       | +------+-----------+ 4 rows in set (0.00 sec)

Delete Multiple Rows from a MySQL Table

Lakshmi Srinivas
Updated on 20-Jun-2020 07:31:13

7K+ Views

We can use DELETE statement along with a WHERE clause, which identifies those multiple rows, to delete multiple rows from MySQL table.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 5    | Ram       | +------+-----------+ 4 rows in set (0.00 sec) mysql> DELETE from names WHERE id > 2; Query OK, 2 rows affected (0.04 sec)The query above will delete multiple rows because WHERE clause identify two rows having id > 2 from table ‘names’.mysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | +------+-----------+ 2 rows in set (0.00 sec)

Increase Duration of jQuery Effects

Kristi Castro
Updated on 20-Jun-2020 07:31:03

356 Views

To increase the duration of jQuery effects, set the optional speed parameter. The values include, slow, fast, milliseconds, etc. The fast value is used to increase the duration.Let us see an example with fadeIn() jQuery method. The fadeIn( ) method fades in all matched elements by adjusting their opacity and firing an optional callback after completion. Here is the description of all the parameters used by this method −speed − A string representing one of the three predefined speeds ("slow", "def", or "fast") or the number of milliseconds to run the animation (e.g. 1000).callback − This is optional parameter representing ... Read More

Adjust Height of iFrame Based on Loaded Content using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:25:20

2K+ Views

To adjust the height of iframe, use the jQuery height() method. You can try to run the following code to adjust height of iframe dynamically on button click:ExampleLive Demo                 $(document).ready(function(){         $("button").click(function(){           $("iframe").height(300);         });       });             Change Height

How does iframe ready Method Work in jQuery

Kristi Castro
Updated on 20-Jun-2020 07:24:24

3K+ Views

Here’s an example wherein the iframe size is larger than the page. We will scroll to the top of the page whenever the iframe loads using jQuery −ExampleLive Demo               $(document).ready(function(){       $("button").click(function(){         $('iframe').ready(function(){           $(window).scrollTop(0);         });       });    });           Loop through each image

Loop Through All Iframe Elements of a Page Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:22:57

1K+ Views

To loop through all the iframes element of a page, use the jQuery each() method. You can try to run the following code to learn how to loop through all iframes. We have created three iframes below −ExampleLive Demo $(document).ready(function(){   $("button").click(function(){     $("iframe").each(function(){       alert($(this).text())       });   }); });   Qries Q/A   Tutorialspoint Free Learning   Send Files   Loop through iFrames

Enable and Disable Submit Button Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:15:21

1K+ Views

To enable and disable submit button, use the jQuery prop() method. You can try to run the following code to enable and disable submit button using jQuery −ExampleLive Demo               $(document).ready(function() {       $('#register').click(function() {         $(this).prop('disabled',true);         $("#content").show();         setTimeout(function(){           $('#register').prop('disabled', false);         },3000);      });    });               The above button disables for 3 seconds, on clicking.                  

Submit Form with Multiple Submit Buttons using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:14:15

3K+ Views

Yes, you can submit form with multiple submit buttons. Attack a custom click handler to all the buttons and the check which button is clicked.ExampleLive Demo               $(document).ready(function(){       $("#myform button").click(function (ev) {       ev.preventDefault()       if ($(this).attr("value") == "button1") {                     alert("First Button is pressed - Form will submit")         $("#myform").submit();       }       if ($(this).attr("value") == "button2") {         alert("Second button is pressed - Form did not submit")       }     }); });     First Button   Second Button

Create DIV Dynamically Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:13:16

2K+ Views

To create a div dynamically, use the html() method. You can try to run the following code to learn how to create a div dynamically on button click −ExampleLive Demo               $(document).ready(function(){       $("button").click(function(){         $("body").html("This is a new div.");       });     });   Create a new div This is demo text.

Get All Unique Rows in MySQL Result Set

Vikyath Ram
Updated on 20-Jun-2020 07:09:52

280 Views

With the help of DISTINCT keyword in SELECT statement, we can get the unique rows in MySQL result set.Examplemysql> Select * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 4    | Aarav     | | 5    | Ram       | | 5    | Ram       | | 5    | Ram       | +------+-----------+ 7 rows in set (0.00 sec)As we can see that table ‘names’ is having three duplicate rows, with the help of following query we can get the result set having only unique rows.mysql> Select DISTINCT * from names; +------+-----------+ | id   | name      | +------+-----------+ | 1    | Rahul     | | 2    | Gaurav    | | 3    | Raman     | | 4    | Aarav     | | 5    | Ram       | +------+-----------+ 5 rows in set (0.00 sec)

Advertisements