Effect of MySQL LAST_INSERT_ID Function on Multiple Row Insert

Jennifer Nicholas
Updated on 20-Jun-2020 07:39:34

273 Views

As we know that MySQL LAST_INSERT_ID() function returns the latest generated sequence number but in case of multiple row-insert it would return the sequence number generated by the foremost inserted row.Examplemysql> Insert into Student(Name) values('Ram'), ('Mohan'), ('Aryan'); Query OK, 3 rows affected (0.03 sec) Records: 3 Duplicates: 0 Warnings: 0The query above inserts three values in Student table with the help of Multiple-row insert query. The value of Column ‘Id’ can be checked with the help of the following query −mysql> Select * from Student; +----+-------+ | Id | Name  | +----+-------+ | 1 | Raman  | | 2 | ... Read More

MySQL ASCII Function Returns Without Parameter

Arjun Thakur
Updated on 20-Jun-2020 07:38:56

203 Views

In this case, it means we are providing an empty string as an argument to the ASCII() function. It will return 0 on providing empty string.Examplemysql> Select ASCII(''); +-----------+ | ASCII('') | +-----------+ |     0     | +-----------+ 1 row in set (0.00 sec)

Get Number Code of a Specific Character in MySQL

Samual Sam
Updated on 20-Jun-2020 07:38:30

126 Views

String function ASCII() in MySQL returns the ASCII number code of the specific character.SyntaxASCII(str)Here, str, the argument of ASCII() function, is the string whose ASCII value of the first character to be retrieved.It is pertinent to mention here that it will return the number code the left the most character i.e. first character of the string given as argument.Examplemysql> SELECT ASCII('A') as 'ASCII VALUE OF CAPITAL A'; +--------------------------+ | ASCII VALUE OF CAPITAL A | +--------------------------+ | 65                       | +--------------------------+ 1 row in set (0.00 sec) mysql> SELECT ... Read More

Use of MySQL LAST INSERT ID Function

radhakrishna
Updated on 20-Jun-2020 07:37:53

318 Views

MySQL LAST_INSERT_ID() function is used to obtain the most recent generated sequence number by AUTO_INCREMENT.ExampleIn this example, we are creating a table named ‘Student’ having an AUTO_INCREMENT column. We insert two values in the column ‘Name’ and when we use INSERT_LAST_ID() function then it returns the most recent generated sequence number i.e. 2.mysql> Create table Student(Id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, Name Varchar(5)); Query OK, 0 rows affected (0.13 sec) mysql> Insert into student(Name) Values('Raman'); Query OK, 1 row affected (0.06 sec) mysql> Insert into student(Name) Values('Rahul'); Query OK, 1 row affected (0.07 sec) mysql> Select* ... Read More

Use of NCHAR in MySQL

Vrundesha Joshi
Updated on 20-Jun-2020 07:37:27

969 Views

MySQL defines NCHAR as a way to indicate that a CHAR column should use predefined character set. Utf8 is used by MySQL as its predefined character set.ExampleIn the example below, we are creating a table named ‘Student1’. In this table, we are declaring the data types of three columns with three different declaration styles which are rather equivalent of each other. It is all due to NCHAR.mysql> Create table Student1(Name Char(10) character set utf8, Address NATIONAL CHARACTER(10), FatherName NCHAR(10));    Query OK, 0 rows affected (0.25 sec)Now on checking the status of table, with the help of query below, we ... Read More

Insert a New Row into a MySQL Table

Moumita
Updated on 20-Jun-2020 07:37:01

1K+ Views

With the help of INSERT INTO command, a new row can be inserted into a table.SyntaxINSERT INTO table_name values(value1, value2, …)ExampleSuppose we have a table named ‘Employee’ with three columns ‘Emp_id’, ‘Emp_name’ and ‘Emp_Sal’ then with the help of following query we can add new rows to the table −mysql> INSERT INTO Employee values(110, 'Aarav', 50000); Query OK, 1 row affected (0.07 sec) mysql> INSERT INTO Employee values(200, 'Raman', 28000); Query OK, 1 row affected (0.10 sec) mysql> Select * from Employee; +---------+-------------+-----------+ | Emp_id  | Emp_name    | Emp_sal   | +---------+-------------+-----------+ | 110     |Aarav ... Read More

Validate Email Using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:36:39

12K+ Views

To validate email using jQuery, use the regex pattern. You can try to run the following code to learn how to validate email using jQuery −ExampleLive Demo               $(document).ready(function() {       $('.error').hide();       $('#submit').click(function(){         var name = $('#name').val();         var email = $('#email').val();         if(name== ''){           $('#name').next().show();           return false;         }         if(email== ''){           ... Read More

MySQL CHARACTER SET Binary Attribute for Character String Data Type

Sravani S
Updated on 20-Jun-2020 07:36:30

216 Views

On specifying a CHARACTER SET binary attribute for a character string data type, MySQL creates that column as its subsequent binary string type. The conversions for CHAR, VARCHAR and BLOB data types take place as follows −CHAR would become BINARYVARCHAR would become VARBINARYTEXT would become BLOBThe above kind of conversion does not occur for ENUM and SET data type and they both are created as declared while creating the table.ExampleIn the example below we have created a table named ‘EMP’ with four columns all specified as CHARACTER SET binary as follows −mysql> Create table Emp(Name varchar(10) CHARACTER SET binary, Address ... Read More

Insert NULL, 0, or No Value to AUTO INCREMENT Column in MySQL

mkotla
Updated on 20-Jun-2020 07:36:00

486 Views

MySQL will automatically assign sequence numbers to the AUTO_INCREMENT column even if we insert NULL, 0 or No Value to the column in a table.Examplemysql> create table test123(id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, Name Varchar(10)); Query OK, 0 rows affected (0.15 sec)The query above created a MySQL table named ‘test123’ with columns named ‘id’ and ‘Name’. The column ‘id’ is declared AUTO_INCREMENT. Now, if we insert ‘No Value’, ‘0’ or ‘NULL’ in the ‘Name’ column, MySQL will assign the sequence numbers to column ‘id’. It can be seen from the result queries below −mysql> Insert Into test123(Name) values(''), ('0'), ... Read More

Select All Children from a Parent in jQuery

Kristi Castro
Updated on 20-Jun-2020 07:35:38

1K+ Views

To select all children from a parent in jQuery, use the find() method. You can try to run the following code to select ALL children in any level −ExampleLive Demo        .myclass * {      display: block;      border: 2px solid lightgrey;      color: lightgrey;      padding: 5px;      margin: 15px;    }         $(document).ready(function(){     $('ul').find('*').css({"color": "red", "border": "2px solid green"});   });     div - great-grandparent   ul    li- child - level 1      ul- child - level 2        li- child - level 3        li- child - level 3                  

Advertisements