MySQL CHAR_LENGTH Function Returns No Parameter

Monica Mona
Updated on 20-Jun-2020 07:48:07

230 Views

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

Retrieve Length of Specified String in MySQL

Alankritha Ammu
Updated on 20-Jun-2020 07:47:20

168 Views

CHAR_LENGTH() or CHARACTER_LENGTH() string functions in MySQL are used to retrieve the length of a specified string. This function will simply count the number of characters and ignores whether the characters are of single-byte or multi-byte.Examplemysql> Select CHAR_LENGTH('New Delhi'); +--------------------------+ | CHAR_LENGTH('New Delhi') | +--------------------------+ | 9                        | +--------------------------+ 1 row in set (0.00 sec) mysql> Select CHAR_LENGTH('NewDelhi'); +-------------------------+ | CHAR_LENGTH('NewDelhi') | +-------------------------+ | 8                       | +-------------------------+ 1 row in set (0.00 sec) mysql> Select CHARACTER_LENGTH('NewDelhi'); ... Read More

Detect Pressing Enter on Keyboard using jQuery

Kristi Castro
Updated on 20-Jun-2020 07:46:52

380 Views

To detect pressing Enter on keyboard, use the keup() function with keyCode. You can try to run the following code to learn how to detect pressing Enter on keyboard using jQuery −ExampleLive Demo                          $(document).ready(function(){          $('textarea').bind("enterKey",function(e){          alert("You have pressed Enter key!");       });       $('textarea').keyup(function(e){          if(e.keyCode == 13)          {             $(this).trigger("enterKey");          }       });    });            Press Enter below         Press Enter below 

Convert While Loop to For Loop in Python

Pythonista
Updated on 20-Jun-2020 07:41:33

1K+ Views

Usin count() function in itertools module gives an iterator of evenly spaced values. The function takes two parameters. start is by default 0 and step is by default 1. Using defaults will generate infinite iterator. Use break to terminate loop.import itertools percentNumbers = [ ] finish = "n" num = "0" for x in itertools.count() :     num = input("enter the mark : ")     num = float(num)     percentNumbers.append(num)     finish = input("stop? (y/n) ")     if finish=='y':break print(percentNumbers)Sample output of the above scriptenter the mark : 11 stop? (y/n) enter the mark : 22 stop? (y/n) enter the mark : 33 stop? (y/n) y [11.0, 22.0, 33.0]

Effect of MySQL LAST_INSERT_ID Function on Multiple Row Insert

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

285 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

223 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

150 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

339 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

992 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

Advertisements