- 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
195 Views
For this, you can use the mid() function. Following is the syntax −select mid(yourColumnName, yourPositionToStart, yourEndValue) as anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('My best framework is Spring and Hibernate'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+-------------------------------------------+ | Title ... Read More
250 Views
For string matching, use LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> MonthName varchar(100) -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JFMA'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('JMA'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JDN'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JFOSA'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement ... Read More
1K+ Views
For this, you can use subquery. Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Name) values('David Miller'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Name) values('Chris Brown'); Query OK, 1 row affected (0.22 sec)Display all records from the table using select statement −mysql> ... Read More
115 Views
Let us first create a table −mysql> create table DemoTable -> ( -> status int -> ); Query OK, 0 rows affected (0.66 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.14 sec) ... Read More
88 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (1.32 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JOhn'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('CHRIS'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('DAVID'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('RObert'); Query OK, 1 row affected (0.21 sec)Display all records from the table using select statement −mysql> select *from DemoTable;Output+--------+ | Name ... Read More
96 Views
The stripos() equivalent in MySQL is INSTR(), which returns the position of the first occurrence of a string in another string. Following is the syntax −select instr(yourColumnName, yourWord) As anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.22 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('MySQL is my favourite subject'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('MongoDB is not my favourite subject'); Query OK, 1 row affected (0.20 sec)Display ... Read More
654 Views
To remove seconds from MySQL datetime, use UPDATE and SET as in the following syntax −update yourTableName set yourDateColumnName=yourDateColumnName -second(yourDateColumnName);Let us first create a table −mysql> create table DemoTable -> ( -> Shippingdatetime datetime -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-01-21 12:05:20'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('2019-03-01 10:23:35'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('2019-06-09 11:00:56'); Query OK, 1 row affected (0.14 sec)Display all records from the table ... Read More
176 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Subject varchar(100) -> ); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Subject) values('C'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(Subject) values('Java'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(Subject) values('MongoDB'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Subject) ... Read More
74 Views
To find the greatest value among four tables, you can use the method GREATEST(). Following is the query to create first table −mysql> create table DemoTable1 -> ( -> Value int -> ); Query OK, 0 rows affected (0.70 sec)Insert some records in the first table using insert command −mysql> insert into DemoTable1 values(10); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1 values(60); Query OK, 1 row affected (0.14 sec)Display all records from the first table using select statement −mysql> select *from DemoTable1;Output+-------+ | Value | +-------+ | 10 | ... Read More
1K+ Views
For this, you can use SHOW COLUMNS command. Following is the syntax. Here, we have set the string using LIKE −SHOW COLUMNS FROM yourTableName LIKE ‘yourStringValue’;Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (0.69 sec)Here is the query to select column names containing a specific string −mysql> SHOW COLUMNS FROM DemoTable LIKE 'FirstName';Output+-----------+-------------+------+-----+----------+-------+ | Field | Type | Null | ... Read More