AmitDiwan has Published 10740 Articles

Insert data in a table in MySQL stored procedure?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:33:13

3K+ Views

To insert in a table in stored procedure, the syntax is as follows −create procedure yourProcedureName(OptionalParameter)    begin    insert into yourTableName() values(yourValue1, yourValue2, ...N); endTo understand the above syntax, let us first create a table −mysql> create table DemoTable1928    (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ... Read More

Display first non-null values with coalesce() in MySQL?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:31:04

526 Views

The coalesce() can be used to print first NOT NULL column value. Let us first create a table −mysql> create table DemoTable1927    (    StudentName varchar(20),    StudentSubject varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

jQuery Traversing Descendants

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:30:10

146 Views

To traverse and find descendants of an element, jQuery has the following methods: children() and find().children() methodThe childreb() method in jQuery is used to return the direct children of the selected element (only a single level of direct children). Let us see an example−Example Live Demo div { ... Read More

How to select rows if initial ones are randomized and the rest ordered by criteria with MySQL?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:28:20

141 Views

For this, you can use ORDER BY CASE statement. Let us create a table −mysql> create table DemoTable1926    (    Position varchar(20),    Number int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1926 values('Highest', 50); Query ... Read More

How to update a specific column value fetched with CASE statement?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:22:10

168 Views

For this, use UPDATE command along with CASE statement. Let us first create a table −mysql> create table DemoTable1925    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20),    StudentMarks int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using ... Read More

Update the records in a table with a specific year fetched from date format like '10/12/2010'?

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:20:19

166 Views

To update records with a specific year, use the YEAR() method as in the below syntax:update yourTableName set yourColumnName1=yourValue1 where YEAR(str_to_date(yourColumnName2, '%d/%m/%Y'))=yourValue2;Let us first create a table −mysql> create table DemoTable1924    (    UserName varchar(20),    UserJoiningDate varchar(40)    ); Query OK, 0 rows affected (0.00 sec)Insert some records ... Read More

jQuery mouseup() with Examples

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:19:20

439 Views

The mouseup() method in jQuery is used to trigger the mouseup event. The event occurs when the left mouse button is releases over the selected element.SyntaxThe syntax is as follows−$(selector).mousedown(func)Above, func is the function to run when mouseup event triggers.ExampleLet us now see an example to implement the jQuery mouseup() ... Read More

MySQL INSERT INTO SELECT into a table with AUTO_INCREMENT

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:17:37

1K+ Views

Let us create a table −mysql> create table DemoTable1923    (    UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    UserName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1923(UserId, UserName)      select 101 as UserId, ... Read More

Delete records from a MySQL table with IN() in a single query

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:16:08

250 Views

Let us create a table −mysql> create table DemoTable1922    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20)    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1922(StudentName) values('Chris'); Query OK, 1 row affected (0.00 ... Read More

Fix a specific column value and display random values for rest of the rows in MySQL

AmitDiwan

AmitDiwan

Updated on 30-Dec-2019 07:14:43

188 Views

For random rows, you can use RAND(), whereas to fix a specific column, use ORDER BY clause. Let us create a table −mysql> create table DemoTable1921    (    Number int    ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert ... Read More

Advertisements