Found 4378 Articles for MySQL

How can we use ASCII() function with MySQL WHERE clause?

Sharon Christine
Updated on 30-Jan-2020 06:41:04

268 Views

While using the ASCII() function with WHERE clause, the output returns by it will depend upon the condition given in WHERE clause. For example, suppose we have a table named ‘Student’ and we want to get the number code, higher than 65, of the first characters of the names of the students. The query for this can be written as follows −mysql> Select * from student; +------+---------+---------+-----------+ | Id   | Name    | Address | Subject   | +------+---------+---------+-----------+ | 1    | Gaurav  | Delhi   | Computers | | 2    | Aarav   | Mumbai  | ... Read More

What MySQL ASCII() function returns if I will provide NULL to it?

Ayyan
Updated on 30-Jan-2020 06:41:55

69 Views

In this case, the output of ASCII() function depends on the condition that whether we are providing NULL as a string or we are providing simply NULL to it. Following example will demonstrate the difference −mysql> SELECT ASCII(null); +-------------+ | ASCII(null) | +-------------+ | NULL        | +-------------+ 1 row in set (0.00 sec) mysql> SELECT ASCII('null'); +---------------+ | ASCII('null') | +---------------+ | 110           | +---------------+ 1 row in set (0.00 sec) mysql> Select ASCII(NULL); +-------------+ | ASCII(NULL) | +-------------+ | NULL        | +-------------+ 1 row in set ... Read More

How can we change MySQL AUTO_INCREMENT starting number?

seetha
Updated on 20-Jun-2020 07:49:06

110 Views

MySQL AUTO_INCREMENT value starts from 1 but we can change it with the help of following two ways −With the help of ALTER TABLE query We can use ALTER TABLE query to change the staring value of AUTO_INCREMENT as follows −ALTER TABLE table_name AUTO_INCREMENT = value;ExampleSuppose we have created a table having column ‘id’ as AUTO_INCREMENT. Now if we will insert the values in it then the sequence number would start from 1 as you can see this in following queries −mysql> Create Table EMP(id int NOT NULL PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(10)); Query OK, 0 rows affected (0.07 sec) ... Read More

What will happen if the MySQL AUTO_INCREMENT column reaches the upper limit of the data type?

vanithasree
Updated on 30-Jul-2019 22:30:21

644 Views

When the AUTO_INCREMENT column reaches the upper limit of data type then the subsequent effort to generate the sequence number fails. That is why it is advised to use a large enough integer data type for the AUTO_INCREMENT column to hold the maximum sequence value required by us. For example, if we will use TINYINT then AUTO_INCREMENT would be able to generate only 127 sequence numbers and in case of UNSIGNED TINYINT, this value can be extended up to 255.

What MySQL ASCII() function returns if no parameter is provided to it?

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

96 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)

What function in MySQL can be used to get the number code of a specific character?

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

68 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

What would be the effect on the output of MySQL LAST_INSERT_ID() function in the case on multiple-row insert?

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

177 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

What is the use of MySQL LAST_INSERT_ID() function?

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

215 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

How can we insert a new row into a MySQL table?

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

901 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

How can we insert data into a MySQL table?

Swarali Sree
Updated on 20-Jun-2020 07:34:22

374 Views

For inserting data into a MySQL table we need to use INSERT INTO command. We must have to specify values for all the columns of the table in INSERT INTO command.SyntaxINSERT INTO table_name values(value1, value2, …)ExampleSuppose we have a table named ‘Student’ with three columns ‘RollNo’, ‘Name’ and ‘Class’ then with the help of following query we can add new rows to the table −mysql> INSERT INTO Student values(50, 'Harshit', ’B.tech’); Query OK, 1 row affected (0.07 sec) mysql> INSERT INTO Student values(56, 'Amit', ’M.tech’); Query OK, 1 row affected (0.05 sec) mysql> Select * from Student; +---------+-------------+-----------+ ... Read More

Advertisements