- 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
2K+ Views
The int is the synonym of integer in MySQL 5.0. Here is the demo display both int and integer internally represents int(11).Creating a table with int datatypemysql> create table IntDemo -> ( -> Id int -> ); Query OK, 0 rows affected (1.04 sec)Here is description of the table. The query is as followsmysql> desc IntDemo;The following is the output+-------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | Id | int(11) | YES | | NULL | | +-------+---------+------+-----+---------+-------+ 1 row in ... Read More
404 Views
You can use substring_index() function from MySQL to split the left part of a string. The syntax is as follows −SELECT yourColumnName1, .....N, SUBSTRING_INDEX(yourColumnName, ’yourSeperatorSymbol’, 1) as anyVariableName from yourTableName;The value 1 indicates that you can get left part of string. To check the above syntax, let us create a table. The query to create a table is as follows −mysql> create table LeftStringDemo -> ( -> Id int, -> Words varchar(100) -> ); Query OK, 0 rows affected (0.92 sec)Insert some records in the table using insert ... Read More
61 Views
To order by a field and list the NULL values first, you need to use the following syntax. This will order in descending order −select yourColumnName from yourTableName group by yourColumnName is null desc, yourColumnName desc;To understand the above syntax, let us first create a table −mysql> create table OrderByNullFirstDemo −> ( −> StudentId int −> ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table with the help of insert command. The query is as follows −mysql> insert into OrderByNullFirstDemo values(100); Query OK, 1 row affected (0.13 sec) mysql> insert into OrderByNullFirstDemo ... Read More
935 Views
To select timestamp data range, use the below syntax −SELECT *FROM yourTableName where yourDataTimeField >= anyDateRange and yourDataTimeField < anyDateRangeTo understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table DateRange −> ( −> DueTime timestamp −> ); Query OK, 0 rows affected (1.34 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into DateRange values('2016-11-13'); Query OK, 1 row affected (0.51 sec) mysql> insert into DateRange values('2016-10-14'); Query OK, 1 row ... Read More
278 Views
To begin auto increment from a specific point, use ALTER command. The syntax is as follows −ALTER TABLE yourTableName auto_increment = anySpecificPoint;To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table AutoIncrementSpecificPoint −> ( −> BookId int auto_increment not null, −> Primary key(BookId) −> ); Query OK, 0 rows affected (0.56 sec)Now you can insert records using insert command.The query is as follows −mysql> insert into AutoIncrementSpecificPoint values(); Query OK, 1 row affected (0.17 sec) ... Read More
1K+ Views
To implement a keyword search in MySQL, you can use LIKE operator. The syntax is as follows −SELECT *FROM yourTableName where yourColumnName Like ‘%anyKeywordName%’ or yourColumnName Like ‘%anyKeywordName%’;To understand it further, let us first create a table. The following is the query to create a table −mysql> create table KeywordSearchDemo −> ( −> StudentId int −> , −> StudentName varchar(100) −> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using INSERT command. The query to insert record is as follows −mysql> insert into KeywordSearchDemo values(100, 'Adam John'); Query OK, 1 ... Read More
88 Views
The concat operator can be used in ORACLE. MySQL use concat() function to perform concatenation.To understand the concat() function, let us create a table. The query to create a table is as follows −mysql> create table ConcatenationDemo −> ( −> Id int, −> Name varchar(100) −> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into ConcatenationDemo values(100, 'John'); Query OK, 1 row affected (0.19 sec) mysql> insert into ConcatenationDemo values(101, 'Sam'); Query ... Read More
95 Views
You do not need to use values whenever you insert the results of a select. To insert the results of select, let us first create two tables.The first table query is as follows −< FirstTableDemo> mysql> create table FirstTableDemo −> ( −> StudentId int, −> StudentName varchar(100) −> ); Query OK, 0 rows affected (0.41 sec)Now create second table and after that insert the second table records in the first table using INSERT SELECT command.The query to create the second table − mysql> create table SecondTableDemo −> ( −> Id int, −> ... Read More
93 Views
The MySQL LIMIT is applied after ORDER BY. Let us check the limit condition. Firstly, we will create a table −mysql> create table LimitAfterOrderBy −> ( −> Id int, −> Name varchar(100) −> ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into LimitAfterOrderBy values(101, 'John'); Query OK, 1 row affected (0.18 sec) mysql> insert into LimitAfterOrderBy values(102, 'Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into LimitAfterOrderBy values(103, 'Bob'); Query OK, 1 row affected (0.21 sec) ... Read More
272 Views
MySQL alias cannot be used with *. However, it can be used for individual column. The syntax is as follows −select anyaliasName.yourColumnName1 as anyaliasName1, anyaliasName.yourColumnName2 as anyaliasName2, anyaliasName.yourColumnName3 as anyaliasName3, anyaliasName.yourColumnName4 as anyaliasName4, . . . . N from yourTableName as anyaliasName;MySQL alias is a variable of table that can be used to access the column name of that particular table. To understand the above syntax, let us create a table.The query to create a table is as follows −mysql> create table TableAliasDemo −> ( −> Id int, −> Name varchar(100), −> Age int −> ... Read More