![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
4K+ Views
To query for string fields with a specific length, use the char_length() or length() from MySQL.SyntaxThe syntax is as follows −Case 1 − Use of char_length()This can be used when we are taking length in a number of characters.The syntax −select *from yourTableName where char_length(yourColumnName)=anySpecificLengthValue;Case 2 − Use of length()This can be used when we are taking the length in bytes.The syntax −select *from yourTableName where length(yourColumnName)=anySpecificLengthValue;To understand the above concept, let us first create a table. The query to create a table is as follows −mysql> create table StringWithSpecificLength -> ( -> Id int, -> Name varchar(100), -> FavouriteLanguage ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
659 Views
Let us learn some points about TINYINT type in MySQL −The TINYINT type takes 1 byte i.e. 8 bits.The TINYINT(N), where N indicates the display width you want.For example, TINYINT(1) can be used to display width which is 1.Let us learn about the minimum and maximum values −The maximum value for tinyint is= (2(8-1)-1) = 127 The minimum value for tinyint is = -(2(8-1)) = -128.The value will be between -128 to 127. This means TINYINT (1) does not affect the maximum and minimum value of tinyint.Let us check it −Firstly, create a table with a column set as TINYINT ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
4K+ Views
You can use date-sub() and now() function from MySQL to fetch the rows added in last hour.SyntaxThe syntax is as follows −select *from yourTableName where yourDateTimeColumnName create table LastHourRecords -> ( -> Id int, -> Name varchar(100), -> Login datetime -> ); Query OK, 0 rows affected (0.67 sec)Insert records in the form of datetime using insert command. The query to insert record is as follows −mysql> insert into LastHourRecords values(1, 'John', ' 2018-12-19 10:00:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into LastHourRecords values(2, 'Carol', '2018-12-19 10:10:00'); Query OK, 1 row affected (0.15 sec) ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
239 Views
To get the original value, use the following syntax −Syntaxselect yourBitColumnName+0 from yourTableName;The above syntax cast the bit column to an integer. To understand the above concept, let us create a table and check how the returning value is blank. We will also see how to get the original value.The query to create a table.mysql> create table BitDemo -> ( -> hasValidId bit not null -> ); Query OK, 0 rows affected (1.21 sec)Insert some records in the table using insert command. The query to insert records is as follows −mysql> insert into BitDemo values(1); Query OK, 1 row affected ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
2K+ Views
Instead of simulating an array variable, use temporary table in MySQL. The syntax is as follows −create temporary table if not exists yourTemporaryTableName select yourColumnName1, yourColumnName2, ......N from yourTableName where conditionTo understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table SimulateArrayDemo -> ( -> Id int, -> FirstName varchar(100), -> LastName varchar(100 -> ) -> ); Query OK, 0 rows affected (1.25 sec)Insert some records in the table using ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
95 Views
Whenever you want all the values like not null for a column then use count(*). This is faster than using count() method.The syntax to use count(*) is as follows −select count(*) as anyVariableName from yourTableName;To understand the above concept, let us first create a table. The query to create a table is as follows −mysql> create table CountingDemo -> ( -> BookId int -> ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into CountingDemo values(100); Query OK, 1 row affected (0.13 sec) ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
7K+ Views
To simulate a print statement in MySQL, you can use select statement. The syntax is as follows −SELECT ‘anyStringValue’ as ’ ‘;You can check the above syntax at the MySQL command line client.Case 1To print a string.mysql> select 'HELLO MYSQL' as ' ';Output+-------------+ | | +-------------+ | HELLO MYSQL | +-------------+ 1 row in set (0.00 sec)Case 2a) To print integer, use the following query −mysql> select 23 as ' ';Output+----+ | | +----+ | 23 | +----+ 1 row in set (0.00 sec)b) To print float or double type, use the following ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
2K+ Views
In order to get the date from the timestamp, you can use DATE() function from MySQL.The syntax is as follows −SyntaxSELECT DATE(yourTimestampColumnName) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table DateFromTimestamp -> ( -> ShippingDateTime timestamp -> ); Query OK, 0 rows affected (0.60 sec)Insert date and time for the column ShippingDateTime we created above.The query to insert record is as follows −mysql> insert into DateFromTimestamp values('2012-12-26 13:24:35'); Query OK, 1 row affected (0.14 sec) mysql> insert into DateFromTimestamp values('2013-11-26 14:36:40'); ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
2K+ Views
To make a primary key start from 1000, you need to alter your table and set to auto_increment with value 1000. The syntax is as follows −alter table yourTableName auto_increment=1000;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table PrimaryKey1000Demo -> ( -> ProductId int auto_increment, -> PRIMARY KEY(ProductId) -> ); Query OK, 0 rows affected (0.56 sec)Now here is the query that will update the primary key to start from 1000 −mysql> alter table PrimaryKey1000Demo auto_increment=1000; Query OK, 0 rows affected (0.20 ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
5K+ Views
You need to store the date as the complete date time rather than storing only month and year. If you declare as a datetime then you can extract the month and year using MONTH() and YEAR() function from MySQL.The syntax is as follows −select MONTH(yourDateTimeColumnName) as anyVariableName1, YEAR(yourDateTimeColumnName) as anyVariableName2 from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table OnlyMonthandYear -> ( -> DueDateTime datetime -> ); Query OK, 0 rows affected (0.56 sec)Insert date in the table using insert command. ... Read More