加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite3:near“.”:语法错误

发布时间:2020-12-12 18:55:22 所属栏目:百科 来源:网络整理
导读:我已经创建了两个表: create table movies(id integer,name text,score integer);create table cast(movie_id integer,cast_id integer,cast_name text); 我需要前10个(不同的,按字母顺序由cast_name)演员和他们的平均电影分数,所以我试过: select movie_i
我已经创建了两个表:

create table movies(id integer,name text,score integer);
create table cast(movie_id integer,cast_id integer,cast_name text);

我需要前10个(不同的,按字母顺序由cast_name)演员和他们的平均电影分数,所以我试过:

select movie_id,cast_id,cast_name,id,score from cast,movies 
where movies.id=cast.movie_id and cast_name in 
(select distinct cast_name from cast order by cast_name limit 10);

但后来我收到一条错误消息:“.”附近. :语法错误

在那之后,我试图让它变得更简单:

select cast_name,movies where movies.id=cast.movie_id;

我仍然有同样的错误.

我想这可能是因为’.’是sqlite3中的一个特殊命令,但无法弄清楚如何解决这个问题.

任何帮助将不胜感激.

解决方法

演员是一个保留字.保留字列表是 here.

select cast_name,score
from `cast` c join
     movies m
     on m.id = c.movie_id;

你可以使用反引号或双引号来逃避它.此查询使用表别名来简化查询和更现代的连接语法.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读