If you want to select id values of 1,2,3 in same query we use IN operator in MySQL
Table Name : user
Id LastName
1 Value1
2 Value2
3 Value3
4 Value4
Id LastName
1 Value1
It select only one value.
By using IN operator
Id LastName
1 Value1
2 Value2
3 Value3
In this query Id 10 is not in the table user
So output like this
Id LastName
1 Value1
2 Value2
Table Name : user
Id LastName
1 Value1
2 Value2
3 Value3
4 Value4
SELECT * FROM `user` WHERE `Id` =1;
Id LastName
1 Value1
It select only one value.
By using IN operator
SELECT * FROM `user` WHERE `Id` IN ('1','2','3');
Id LastName
1 Value1
2 Value2
3 Value3
SELECT * FROM `user` WHERE `Id` IN ('1','2','10');
In this query Id 10 is not in the table user
So output like this
Id LastName
1 Value1
2 Value2
0 comments:
Post a Comment