![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
Difference between intvalue='1' and intvalue=1 in MySQL?
You need to use intvalue=1. The statement intvalue=’1’ is internally converted to cast(‘1’ as int) by MySQL.
Let us first create a table −
mysql> create table DemoTable1566 -> ( -> intvalue int -> ); Query OK, 0 rows affected (0.64 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1566 values(1); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1566 values(55); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1566 values(75); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable1566 values(90); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1566;
This will produce the following output −
+----------+ | intvalue | +----------+ | 1 | | 55 | | 75 | | 90 | +----------+ 4 rows in set (0.00 sec)
Here is the query to implement intvalue=1 −
mysql> select * from DemoTable1566 where intvalue=1;
This will produce the following output −
+----------+ | intvalue | +----------+ | 1 | +----------+ 1 row in set (0.00 sec)
Here is the query to intvalue=’1’ −
mysql> select * from DemoTable1566 where intvalue='1';
This will produce the following output −
+----------+ | intvalue | +----------+ | 1 | +----------+ 1 row in set (0.00 sec)
Advertisements