Select 语句在行值中看不到 @ 后面的字符

发布于 2024-09-07 09:29:22 字数 1252 浏览 2 评论 0原文

很奇怪的问题。将电子邮件地址保存到我的数据库中,但是当我查询这些电子邮件地址时,它显示为 name@ 而不是 [电子邮件受保护]。我怀疑正在进行一些内部过滤,但不知道如何解决。

CREATE TABLE  `bredeschool`.`users` (
  `userID` smallint(6) NOT NULL AUTO_INCREMENT,
  `gebruikersnaam` varchar(10) NOT NULL,
  `wachtwoord` varchar(10) NOT NULL,
  `type` varchar(20) NOT NULL,
  `aanmaakDatum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `wijzigingsDatum` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`userID`),
  UNIQUE KEY `userID` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

INSERT INTO users (gebruikersnaam, wachtwoord, type, aanmaakdatum, wijzigingsdatum) VALUES ('[email protected]', 'xxxx', 'ouder', '2010-06-25 15:16:40', '2010-06-25 15:16:40');

SELECT * FROM users WHERE gebruikersnaam = '[email protected]';

最后一次查询没有产生结果。不带 WHERE 执行会将电子邮件地址显示为 name@。

谢谢, 克里斯

Very weird problem. Saving email addresses to my database, but when I query those emailaddresses it shows up as name@ instead of [email protected]. I suspect some internal filtering going on but have no idea how to solve it.

CREATE TABLE  `bredeschool`.`users` (
  `userID` smallint(6) NOT NULL AUTO_INCREMENT,
  `gebruikersnaam` varchar(10) NOT NULL,
  `wachtwoord` varchar(10) NOT NULL,
  `type` varchar(20) NOT NULL,
  `aanmaakDatum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `wijzigingsDatum` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`userID`),
  UNIQUE KEY `userID` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

INSERT INTO users (gebruikersnaam, wachtwoord, type, aanmaakdatum, wijzigingsdatum) VALUES ('[email protected]', 'xxxx', 'ouder', '2010-06-25 15:16:40', '2010-06-25 15:16:40');

SELECT * FROM users WHERE gebruikersnaam = '[email protected]';

The last query does not yield a result. Executing without WHERE shows the emailaddress as name@.

Thanx,
Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时光病人 2024-09-14 09:29:22

不确定插入问题,但您要搜索的电子邮件地址有 16 个字符,而 varchar 字段“gebruikersnaam”只有 10 个字符宽。可能只是您的表定义不够宽,无法存储您尝试放入其中的数据。

not sure about the insert issue, but the email address you're searching for is 16 characters, and the varchar field 'gebruikersnaam' is only 10 characters wide. It may be just that your table definition isn't wide enough to store the data you are trying to put in it.

得不到的就毁灭 2024-09-14 09:29:22

该问题似乎与 varchar 的大小有关。尝试使用 varchar(100) 作为 gebruikersnaam 字段。

CREATE TABLE `users` (
  `userID` smallint(6) NOT NULL AUTO_INCREMENT,
  `gebruikersnaam` varchar(100) NOT NULL,
  `wachtwoord` varchar(10) NOT NULL,
  `type` varchar(20) NOT NULL,
  `aanmaakDatum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `wijzigingsDatum` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`userID`),
  UNIQUE KEY `userID` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

Query OK, 0 rows affected (0.05 sec)


INSERT INTO users 
    (gebruikersnaam, wachtwoord, type, aanmaakdatum, wijzigingsdatum) 
VALUES 
    ('[email protected]', 'xxxx', 'ouder', '2010-06-25 15:16:40', '2010-06-25 15:16:40');

Query OK, 1 row affected (0.00 sec)

最后一个查询现在产生结果:

SELECT * FROM users WHERE gebruikersnaam = '[email protected]';

+--------+------------------+------------+-------+---------------------+---------------------+
| userID | gebruikersnaam   | wachtwoord | type  | aanmaakDatum        | wijzigingsDatum     |
+--------+------------------+------------+-------+---------------------+---------------------+
|     15 | [email protected] | xxxx       | ouder | 2010-06-25 15:16:40 | 2010-06-25 15:16:40 |
+--------+------------------+------------+-------+---------------------+---------------------+
1 row in set (0.00 sec)

The problem appears to be related to the size of the varchar. Try using varchar(100) for the gebruikersnaam field.

CREATE TABLE `users` (
  `userID` smallint(6) NOT NULL AUTO_INCREMENT,
  `gebruikersnaam` varchar(100) NOT NULL,
  `wachtwoord` varchar(10) NOT NULL,
  `type` varchar(20) NOT NULL,
  `aanmaakDatum` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `wijzigingsDatum` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`userID`),
  UNIQUE KEY `userID` (`userID`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8;

Query OK, 0 rows affected (0.05 sec)


INSERT INTO users 
    (gebruikersnaam, wachtwoord, type, aanmaakdatum, wijzigingsdatum) 
VALUES 
    ('[email protected]', 'xxxx', 'ouder', '2010-06-25 15:16:40', '2010-06-25 15:16:40');

Query OK, 1 row affected (0.00 sec)

The last query yields a result now:

SELECT * FROM users WHERE gebruikersnaam = '[email protected]';

+--------+------------------+------------+-------+---------------------+---------------------+
| userID | gebruikersnaam   | wachtwoord | type  | aanmaakDatum        | wijzigingsDatum     |
+--------+------------------+------------+-------+---------------------+---------------------+
|     15 | [email protected] | xxxx       | ouder | 2010-06-25 15:16:40 | 2010-06-25 15:16:40 |
+--------+------------------+------------+-------+---------------------+---------------------+
1 row in set (0.00 sec)
命硬 2024-09-14 09:29:22

发生这种情况可能是因为您的 gebruikersnaam 列长度太短。我认为你应该将其更改为 VarChar (50)

That is happening probably because your gebruikersnaam column is too short in length. I think you should change it to VarChar (50)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文