- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4219 Articles for MySQLi
936 Views
To select rows with more than 2 decimal places, use SUBSTR() function from MySQL. Let us first create a table −mysql> create table selectRows2DecimalPlacesDemo -> ( -> Amount varchar(100) -> ); Query OK, 0 rows affected (0.73 sec)Following is the query to insert records in the table using insert command −mysql> insert into selectRows2DecimalPlacesDemo values('234.5678'); Query OK, 1 row affected (0.17 sec) mysql> insert into selectRows2DecimalPlacesDemo values('19.50'); Query OK, 1 row affected (0.19 sec) mysql> insert into selectRows2DecimalPlacesDemo values('23.456'); Query OK, 1 row affected (0.17 sec) mysql> insert into selectRows2DecimalPlacesDemo values('12.123'); Query OK, 1 row affected (0.14 ... Read More
380 Views
To replace part of string in MySQL table column, you can use REPLACE(). Following is the syntax −update yourTableName set yourColumnName = REPLACE(yourColumnName ,'yourOldValue', 'yourNewValue');Let us first create a table −mysql> create table replacePartOfStringDemo -> ( -> WebsiteURL varchar(100) -> ); Query OK, 0 rows affected (0.47 sec)Following is the query to insert records in the table using insert command −mysql> insert into replacePartOfStringDemo(WebsiteURL) values('www.mysqlQuestion.com'); Query OK, 1 row affected (0.14 sec)Following is the query to display all records from the table using select statement −mysql> select * from replacePartOfStringDemo;This will produce the following output −+-----------------------+ | ... Read More
1K+ Views
To strip all spaces from a column in MySQL, you can use REPLACE() function. Following is the syntax −update yourTableName set yourColumnName=REPLACE(yourColumnName, ' ', '' );Let us first create a table −mysql> create table stripAllSpacesDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.56 sec)Following is the query to insert records in the table using insert command −mysql> insert into stripAllSpacesDemo(Name) values('Jo h n'); Query OK, 1 row affected (0.19 sec) mysql> insert into stripAllSpacesDemo(Name) values(' Joh n'); Query OK, 1 row affected (0.16 ... Read More
3K+ Views
To insert a NULL value, you can use UPDATE command. Following is the syntax −UPDATE yourTableName SET yourColumnName=NULL;Let us first create a table −mysql> create table insertNullValue -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(100), -> ClientCountryName varchar(20) -> ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert some records in the table using insert command −mysql> insert into insertNullValue(ClientName, ClientCountryName) values('Larry', 'US'); Query OK, 1 row affected (0.19 sec) mysql> insert into insertNullValue(ClientName, ClientCountryName) values('David', 'AUS'); Query OK, 1 row affected (0.09 sec) ... Read More
472 Views
If you want to check privileges for a specific user, then use the below syntax −SHOW GRANTS FOR 'yourUserName'@'yourHostName';The above syntax will check privileges for a specific user.To check the privileges for a specific user, then use FOR. Let’s say we have a username ‘JOHN‘ and host is ‘%’. Following is the query to get the privileges for user “JOHN” −mysql> SHOW GRANTS FOR 'JOHN'@'%';This will produce the following output −+--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | Grants for JOHN@% | +--------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------- --------------+ | GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, ... Read More
2K+ Views
To remove NULL records in a column, you can use delete command. Following is the syntax −delete from yourTableName where yourColumnName IS NULL;Let us first create a table −mysql> create table removeNullRecordsDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)Following is the query to insert records in the table using insert command −mysql> insert into removeNullRecordsDemo values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into removeNullRecordsDemo values(null); Query OK, 1 row affected (0.15 sec) mysql> insert into removeNullRecordsDemo values('Larry'); Query OK, 1 row affected (0.19 sec) ... Read More
274 Views
You can use LPAD() from MySQL to pad the beginning of a MySQL INT field with zeroes. Let us first create a table.mysql> create table paddingDemo -> ( -> Number int -> ); Query OK, 0 rows affected (0.49 sec)Following is the query to insert some records in the table using insert command −mysql> insert into paddingDemo values(78); Query OK, 1 row affected (0.14 sec) mysql> insert into paddingDemo values(560); Query OK, 1 row affected (0.17 sec) mysql> insert into paddingDemo values(888995); Query OK, 1 row affected (0.13 sec) mysql> insert into paddingDemo values(999994); ... Read More
466 Views
In order to remove partial text from value, you can use REPLACE() from MySQL. Following is the syntax −update yourTableName set yourColumnName = replace(yourColumnName ,'yourValue ', '' );Let us first create a table −mysql> create table removePartialTextDemo -> ( -> JavaVersionDetails varchar(100) -> ); Query OK, 0 rows affected (0.51 sec)Following is the query to insert some records in the table using insert command −mysql> insert into removePartialTextDemo values('Java Version 1.0'); Query OK, 1 row affected (0.50 sec) mysql> insert into removePartialTextDemo values('Java Version 1.1'); Query OK, 1 row affected (0.23 sec) mysql> insert into ... Read More
623 Views
For this, use ORDER BY along with GROUP BY clause. Let us first create a table with Student Name and Score −mysql> create table countRowValueDemo -> ( -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> StudentName varchar(20), -> StudentMathScore int -> ); Query OK, 0 rows affected (0.71 sec)Following is the query to insert records in the table using insert command −mysql> insert into countRowValueDemo(StudentName, StudentMathScore) values('Larry', 45); Query OK, 1 row affected (0.19 sec) mysql> insert into countRowValueDemo(StudentName, StudentMathScore) values('Mike', 56); Query OK, 1 row affected (0.16 sec) mysql> insert into ... Read More
94 Views
Assume that the date is in varchar data type i.e. not in the date format.Let us first create a table. Following is the query −mysql> create table convertDateDemo -> ( -> AdmissionDate varchar(200) -> ); Query OK, 0 rows affected (0.63 sec)Following is the query to insert some records in the table using insert command −mysql> insert into convertDateDemo values('April 04 2019'); Query OK, 1 row affected (0.18 sec) mysql> insert into convertDateDemo values('May 05 2018'); Query OK, 1 row affected (0.16 sec) mysql> insert into convertDateDemo values('January 01 2012'); Query OK, 1 row affected ... Read More