Example Table
- Create table
- Insert records
SQL
-- create table
CREATE TABLE tests (id int AUTO_INCREMENT, foo varchar(255), PRIMARY KEY (id));
-- Insert records
INSERT INTO tests (foo) VALUES ('36'), ('36A'), ('36B'), ('36C'), ('baz');
Run:
SELECT * FROM tests where foo in ('36');
Result:
+----+------+
| id | foo |
+----+------+
| 1 | 36 |
+----+------+
Then run: SELECT * FROM tests where foo in (36);
Result:
+----+------+
| id | foo |
+----+------+
| 1 | 36 |
| 2 | 36A |
| 3 | 36B |
| 4 | 36C |
+----+------+
Question
- Why does passing
36
(as integer) not return the one identical record as passing'36'
(as string) does? - Passing
3
results in an empty set. So I don't quite understand the logic.