在 iPhone 上加入 SQLITE

发布于 2024-10-20 23:27:21 字数 659 浏览 2 评论 0原文

我有一个 SQLite 请求要做,但我不知道该怎么做。

这是:

SELECT videoid,inappid FROM store,video 
WHERE store.paid='1' AND store.checked='1' 
AND video.inappid=store.inappid AND video.download =='0' 
ORDER BY video.inappid DESC,video.videoid;

--> SQL ERROR 答案:DB 错误:1 “不明确的列名:inappid”

我解释一下:store 和 video 是 2 个表。 在商店中,有“inappid”(com.mysite.myapp.000) 引用的产品。 'inappid' 列名是表中的键并且是唯一的。已付款和已检查只是存储表中的布尔值。

在视频中,有...视频,每个视频都有一个唯一的密钥“videoid”。引用存储表中 inappid 的“inappid”列。

所以我的请求是:选择商店表中元素的所有 inappid 参数,其中付费和检查为 TRUE,并选择视频表中带有此 inappid 的视频的所有 videoid,其中该视频尚未下载。

我知道我必须使用 JOIN 和 ON 元素,但我不知道如何

请帮助 Oo。

I have a SQLite request to do and I don't know how to do it.

Here it is :

SELECT videoid,inappid FROM store,video 
WHERE store.paid='1' AND store.checked='1' 
AND video.inappid=store.inappid AND video.download =='0' 
ORDER BY video.inappid DESC,video.videoid;

--> SQL ERROR answer : DB Error: 1 "ambiguous column name: inappid"

I explain : store and video are 2 tables.
in store, there is product referenced by 'inappid' (com.mysite.myapp.000). 'inappid' column name is the key in the table and is unique. paid and checked are just boolean in the store table.

in video, there is... video and each video has a unique key 'videoid'. an 'inappid' column that refers to the inappid in the store table.

So my request was : select me all the inappid params of element in the store table where paid and checked are TRUE and SELECT me all the videoid of video with this inappid in the video table WHERE this video is not already downloaded.

I know I must use JOIN and ON element but I don't know how

please help Oo.

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

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

发布评论

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

评论(2

幽蝶幻影 2024-10-27 23:27:21

由于两个表都包含一列 inappid,因此当您说 SELECT videoid,inappid FROM ... 时,它不知道您要返回哪一列。

一个简单的解决方案是明确选择一个:SELECT videoid,video.inappid FROM ...

另一种解决方案是使用 JOIN 和 USING 进行连接,在这种情况下,它将知道“inappid”两个表中的列是等效的:SELECT videoid,inappid FROM store JOIN video USING(inappid) WHERE store.paid='1' AND store.checked='1' AND video.download =='0' ORDER BY video .inappid DESC,video.videoid

Because both tables contain a column inappid, it doesn't know which one you are wanting to return when you say SELECT videoid,inappid FROM ....

One simple solution is to just explicitly pick one: SELECT videoid,video.inappid FROM ...

Another solution is to do your join using JOIN and USING, in which case it will know that the "inappid" columns in both tables are equivalent: SELECT videoid,inappid FROM store JOIN video USING(inappid) WHERE store.paid='1' AND store.checked='1' AND video.download =='0' ORDER BY video.inappid DESC,video.videoid

哑剧 2024-10-27 23:27:21
SELECT store.videoid, video.inappid FROM store,video 
WHERE store.paid='1' AND store.checked='1' 
AND video.inappid=store.inappid AND video.download =='0' 
ORDER BY video.inappid DESC,video.videoid;

或许?

SELECT store.videoid, video.inappid FROM store,video 
WHERE store.paid='1' AND store.checked='1' 
AND video.inappid=store.inappid AND video.download =='0' 
ORDER BY video.inappid DESC,video.videoid;

Maybe?

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