here is the mysql
CREATE TABLE `demo` (
`account` varchar(30) NOT NULL,
`num` bigint(20) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `demo` (`account`, `num`) VALUES
('5000000000000000001', 5000000000000000001),
('5000000000000000002', 5000000000000000002);
when I write sql select records in php like this:
$accounts = ['5000000000000000001'];
$sql = 'SELECT * FROM `demo` WHERE `account` in ('. implode(',', $accounts).')';
and the $sql
will cause the wrong query result. all the rows are select. then my question is
- what's the best column type should I choice for like number string. when
strlen(account) > 20
or even length larger than 30 next time. - how to write the sql when query for account collection in php.
thanks.