- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
362 Views
The CONCAT() method is used to concat, whereas GROUP_CONCAT() is used to concatenate strings from a group in a single string.Let us first create a table −mysql> create table DemoTable799 ( UserId int, UserName varchar(100), UserAge int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable799 values(101, 'John', 21); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable799 values(102, 'Chris', 26); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable799 values(101, 'Robert', 23); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
Let’s see when the #1054 error occurs in MySQL. While inserting a varchar value, if you will forget to add single quotes, then this error will arise. Following is the error −mysql> insert into DemoTable798 values(100, Adam); ERROR 1054 (42S22): Unknown column 'Adam' in 'field list'You need to use single quotes around the string value to fix this error as shown below −mysql> insert into DemoTable798 values(100, ’Adam’);Let us first create a table −mysql> create table DemoTable798 ( StudentId int, StudentName varchar(100) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
176 Views
The correct datetime format for MySQL database is as follows −‘YYYY-MM-DD HH:M:SS’Let us first create a table −mysql> create table DemoTable797 ( ArrivalDatetime datetime ); Query OK, 0 rows affected (0.68 sec)Insert some records in the table using insert command −mysql> insert into DemoTable797 values(NOW()); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable797 values('2016-12-21 12:50:34'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable797 values('2017-03-01 17:40:21'); Query OK, 1 row affected (0.24 sec)Display all records from the table using select statement −mysql> select *from DemoTable797;This will produce the following output. We have ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
877 Views
Use the DAYNAME() to display the day name from records with Date of Birth.Let us first create a table −mysql> create table DemoTable795 ( DateOfBirth date ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable795 values('1996-01-21'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable795 values('2004-11-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable795 values('1990-03-31'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable795 values('2010-12-03'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
147 Views
To display number of fields in MySQL, use the COUNT(*). Following is the syntax −select COUNT(*) AS anyAliasName from INFORMATION_SCHEMA.COLUMNS where table_name = yourTableName AND TABLE_SCHEMA = yourDatabaseName;Let us first create a table −mysql> create table DemoTable794 ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100), ClientAge int, ClientCountryName varchar(100) ); Query OK, 0 rows affected (1.61 sec)Following is the query to get the number of fields in MySQL −mysql> select COUNT(*) AS TOTAL_NUMBER_OF_COLUMNS from INFORMATION_SCHEMA.COLUMNS where table_name = 'DemoTable794' AND ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
2K+ Views
To check records which are NULL, use IS NULL. However, to exclude any of the records, use the NOT IN clause. Use both of them in the same query.Let us first create a table −mysql> create table DemoTable793 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command −mysql> insert into DemoTable793(StudentName) values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable793(StudentName) values('Bob'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable793(StudentName) values(null); Query ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
83 Views
To reshuffle the values in a table, use MySQL RAND().Let us first create a table −mysql> create table DemoTable792 ( Name varchar(100), Subject varchar(100) ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable792 values('Chris', 'MySQL'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable792 values('David', 'MySQL'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable792 values('Robert', 'MongoDB'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable792 values('Carol', 'MongoDB'); Query OK, 1 row affected (0.18 sec)Display all records ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Use NOT IN() to exclude some of the values from the table.Let us first create a table −mysql> create table DemoTable791 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100) ); Query OK, 0 rows affected (0.61 sec)Insert some records in the table using insert command −mysql> insert into DemoTable791(FirstName) values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable791(FirstName) values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable791(FirstName) values('David'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable791(FirstName) values('Mike'); Query OK, 1 row affected (0.11 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
101 Views
Let us first create a table −mysql> create table DemoTable790 ( Score1 int, Score2 int ); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command −mysql> insert into DemoTable790 values(98, 76); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable790 values(78, 89); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable790 values(85, 68); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable790;This will produce the following output -+--------+--------+ | Score1 | Score2 | +--------+--------+ ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
645 Views
To check for the 1st letter of the first and last name, you need to use the LEFT().Let us first create a table −mysql> create table DemoTable789 ( FirstName varchar(100), LastName varchar(100) ); Query OK, 0 rows affected (0.78 sec)Insert some records in the table using insert command −mysql> insert into DemoTable789 values('Adam', 'Smith'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable789 values('Tom', 'Taylor'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable789 values('Bob', 'Brown'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable789 values('David', 'Miller'); Query ... Read More