- 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
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
311 Views
To check if table exists, use the following syntax −CREATE TABLE IF NOT EXISTS yourTableName ( yourColumnName1 dataType, . . . . N );Here, we will try to create a table that already exists and then it will produce a warning message “Table already exists”. Let us first create a table. This table already exists −mysql> CREATE TABLE IF NOT EXISTS DemoTable ( Id int ); Query OK, 0 rows affected, 1 warning (0.06 sec)The warning message is as follows −mysql> show warnings;Output+-------+------+-------------------------------------+ | Level | Code | Message ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
727 Views
Let us first create a table −create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ShippingDate timestamp );Insert some records in the table using insert command. Here, we have included the current date with NOW() −INSERT INTO DemoTable(ShippingDate) VALUES(now());Display all records from the table using select statement −SELECT *FROM DemoTable;OutputFollowing is the screenshot of query in MySQL workbench to set NOW() to timestamp field “ShippingDate”. The query also displays the output below −
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
289 Views
Yes, it is possible with triggers. You can create trigger for automatic conversion on lower case. Let us first create a table −mysql> create table DemoTable ( StudentSubject text ); Query OK, 0 rows affected (0.61 sec)Let us create a trigger for automatic conversion on lower case −mysql> CREATE TRIGGER lowerCaseOnInsertDemo BEFORE INSERT ON DemoTable FOR EACH ROW SET NEW.StudentSubject = LOWER(NEW.StudentSubject); Query OK, 0 rows affected (0.21 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MOngoDb'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('JaVA'); Query OK, ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
112 Views
Use LIKE for this, as shown below −select *from yourTableName where yourColumnName LIKE 'A%';Let us first create a table −mysql> create table DemoTable ( StudentName varchar(100) ); Query OK, 0 rows affected (0.66 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('Adam Smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Aaron Taylor'); Query OK, 1 row affected (0.43 sec) mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.27 sec)Display ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
276 Views
To display two decimals, use number_format(). Let us first write the PHP code for the same. We have first declared two variables are initialized −$number1=10.3423; $number2=10;Now, display the two decimals using the number_format() function −$result1=number_format ($number1, 2); $result2=number_format ($number2, 2);ExampleFollowing is the example −OutputFollowing is the snapshot of PHP code −10.34 10.00
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
103 Views
To split a numerical query result, you can use the CONCAT() function in MySQL. Let us first create a table −mysql> create table DemoTable ( StudentId int ); Query OK, 0 rows affected (0.68 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(2222); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(5555); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(4567); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(8905); Query OK, 1 row affected (0.15 sec)Display all records from ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
245 Views
No, name is not a reserved word in MySQL, you can use without backtick symbol. If you are working on a reserved word then use backtick symbol. Let us first create a table −mysql> create table name ( name varchar(10) ); Query OK, 0 rows affected (0.78 sec)Now you can insert some records in the table using insert command −mysql> insert into name values('John'); Query OK, 1 row affected (0.13 sec) mysql> insert into name values('Carol'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from name;Output+-------+ | name ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
149 Views
For this, use the ORDER BY clause. Let us first create a table −mysql> create table DemoTable ( StudentId int ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(70); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(55); Query OK, 1 row affected ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
5K+ Views
For this, use STR_TO_DATE(). Following is the syntax −insert into yourTableName values(STR_TO_DATE(yourDateValue, yourFormatSpecifier));Let us first create a table −mysql> create table DemoTable ( ShippingDate date ); Query OK, 0 rows affected (0.81 sec)Insert some records in the table using insert command : Here, we are inserting formatted dates using date formats like m, d, y, etc −mysql> insert into DemoTable values(STR_TO_DATE('06-01-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('01-31-2019', '%m-%d-%Y')); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(STR_TO_DATE('02-01-2018', '%m-%d-%Y')); Query OK, 1 row affected (0.27 sec)Display all records ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
233 Views
To get the day name from timestamp, use dayname() function −select dayname(yourColumnName) from yourTableName; Let us first create a table : mysql> create table DemoTable ( LoginDate timestamp ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('2019-06-02'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-03'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-06-04'); Query OK, 1 row affected (0.11 sec) mysql> insert into ... Read More