sqlite3从多个表中选择’where’的东西

前端之家收集整理的这篇文章主要介绍了sqlite3从多个表中选择’where’的东西前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试一次查询多个表.假设我有一个名为PRESCHOOLERS的表,我有一个名为FAVORITE_GOOEY_TREATS的表,在PRESCHOOLERS表中引用了一个外键列,引用了FAVORITE GOOEY TREAT的id字段.如果我想获得一份带有他们的名字和他们最喜欢的零食的学龄前儿童名单,我该怎么办?我的意思是:
first_name    |    treat
john          |  fudge
sally         |  ice-cream

这是我正在尝试的,但我在where部分有语法错误.

SELECT PRESCHOOLERS.first_name,FAVORITE_GOOEY_TREATS.name as treat
FROM PRESCHOOLERS,FAVORITE_GOOEY_TREATS
WHERE PRESCHOOLERS.favorite_treat = FAVORITE_GOOEY_TREATS.id and PRESCHOOLERS.age>15;

据我所知,这种事情可以通过sql标准,但sqlite3不太喜欢它.有人能指出一些类似查询的例子吗?

尝试
SELECT PRESCHOOLERS.first_name,FAVORITE_GOOEY_TREATS.name as treat
FROM PRESCHOOLERS
JOIN FAVORITE_GOOEY_TREATS ON PRESCHOOLERS.favorite_treat = FAVORITE_GOOEY_TREATS.id
WHERE PRESCHOOLERS.age > 15;
原文链接:https://www.f2er.com/sqlite/197715.html

猜你在找的Sqlite相关文章