作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在执行非常简单的 MySQL 查询时遇到问题。我正在表中搜索字符串字段具有特定值的行。如果我要比较的字符串在引号中,我会收到“未知列”错误。如果字符串不在引号中,我会收到“非法双重错误”。
我提出的查询是(不带引号):
SELECT * FROM `userprofile_userprofile` WHERE `userprofile_userprofile`.`firebaseUID` = 4929e406-9d75-43e2-afa4-fe641f3e85f5
和(字符串两边加引号):
SELECT * FROM `userprofile_userprofile` WHERE `userprofile_userprofile`.`firebaseUID` = `4929e406-9d75-43e2-afa4-fe641f3e85f5`
这是我的表格和内容:
DROP TABLE IF EXISTS `userprofile_userprofile`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `userprofile_userprofile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`firebaseUID` varchar(100) NOT NULL,
`user_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`),
CONSTRAINT `userprofile_userprofile_user_id_59dda034_fk_auth_user_id` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `userprofile_userprofile`
--
LOCK TABLES `userprofile_userprofile` WRITE;
/*!40000 ALTER TABLE `userprofile_userprofile` DISABLE KEYS */;
INSERT INTO `userprofile_userprofile` VALUES (1,'bdbe350a-9c96-4cc0-94f1-5406a9aaa3e7',17),(2,'4929e406-9d75-43e2-afa4-fe641f3e85f5',18);
/*!40000 ALTER TABLE `userprofile_userprofile` ENABLE KEYS */;
UNLOCK TABLES;
最佳答案
您需要将字符串单引号 (''
) 放在反引号 (``) 中,如下所示:
SELECT * FROM `userprofile_userprofile`
WHERE `userprofile_userprofile`.`firebaseUID` = '4929e406-9d75-43e2-afa4-fe641f3e85f5'
关于MySQL 字符串比较查询给出意外的双列或未知列错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36694234/
这个问题在这里已经有了答案: Expand a div to fill the remaining width (21 个回答) 关闭 5 年前。
您好,我正在尝试制作一个简单的 2 列布局(实际上是表格转换),但遇到了问题。HTML: Title: Bla
听起来这应该是一个常见的问题,但我没有找到明显的技巧。 考虑下面的 knitr Rnw 文件, \documentclass[twocolumn, 12pt]{article} \usepackage
我是 Go 的新手,我几天前才开始学习它的并发性:-)。我有一个不同的库,它返回一个 time.Duration 类型,它有 Seconds,一个我想使用并存储在数据库中的 float64 精度值。
我是一名优秀的程序员,十分优秀!