#1054 - 未知列“de15a674d1252f6565a65756ebfa97e8e1e58c9c”在“where 子句”中
我有两个表
CREATE TABLE IF NOT EXISTS `user` ( `user_id` int(20) NOT NULL AUTO_INCREMENT, `ud_id` varchar(50) NOT NULL, `name` text NOT NULL, `password` text NOT NULL, `email` varchar(200) NOT NULL, `image` varchar(150) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB
,mycatch 表是
CREATE TABLE IF NOT EXISTS `mycatch` ( `catch_id` int(11) NOT NULL AUTO_INCREMENT, `catch_name` text NOT NULL, `catch_details` text NOT NULL, `longitude` float(10,6) NOT NULL, `latitude` float(10,6) NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `image` varchar(150) NOT NULL, `user_id` int(20) NOT NULL, PRIMARY KEY (`catch_id`), KEY `user_id` (`user_id`) ) ENGINE=InnoDB; ALTER TABLE `mycatch` ADD CONSTRAINT `mycatch_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
我想从两个表中检索数据。即,
SELECT longitude,latitude FROM user u LEFT JOIN mycatch m ON u.user_id = m.user_id WHERE u.ud_id =de15a674d1252f6565a65756ebfa97e8e1e58c9c AND m.catch_id >7
但这给了我错误 #1054 - 'where 子句' 中的未知列 'de15a674d1252f6565a65756ebfa97e8e1e58c9c'
但是当我更改 u.ud_id=123456789 时它工作正常
i have two tables
CREATE TABLE IF NOT EXISTS `user` ( `user_id` int(20) NOT NULL AUTO_INCREMENT, `ud_id` varchar(50) NOT NULL, `name` text NOT NULL, `password` text NOT NULL, `email` varchar(200) NOT NULL, `image` varchar(150) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB
and mycatch table is
CREATE TABLE IF NOT EXISTS `mycatch` ( `catch_id` int(11) NOT NULL AUTO_INCREMENT, `catch_name` text NOT NULL, `catch_details` text NOT NULL, `longitude` float(10,6) NOT NULL, `latitude` float(10,6) NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `image` varchar(150) NOT NULL, `user_id` int(20) NOT NULL, PRIMARY KEY (`catch_id`), KEY `user_id` (`user_id`) ) ENGINE=InnoDB; ALTER TABLE `mycatch` ADD CONSTRAINT `mycatch_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
i want to retrieve data from both the tables. i.e
SELECT longitude,latitude FROM user u LEFT JOIN mycatch m ON u.user_id = m.user_id WHERE u.ud_id =de15a674d1252f6565a65756ebfa97e8e1e58c9c AND m.catch_id >7
but this give me error #1054 - Unknown column 'de15a674d1252f6565a65756ebfa97e8e1e58c9c' in 'where clause'
but when i change u.ud_id=123456789 then it works fine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 u.ud_id 用单引号引起来
you need single quotes around the u.ud_id
您需要将您的值放在引号中:
You need to put your value in quotes: