- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
SELECT country.continent, country.name, city.district, city.name, city.population
FROM world.country, world.city
WHERE city.population < 3000000
LIMIT 20, 30;
我得到的是笛卡尔积,而不是显示 select 子句内容的表格,其中城市人口超过 300 万。
world是数据库的名称国家和城市是表
请帮忙。
最佳答案
您需要将表连接在一起:
SELECT country.continent, country.name, city.district, city.name, city.population
FROM world.country JOIN
world.city
ON country.code = city.countrycode
WHERE city.population < 3000000
LIMIT 20, 30;
作为编写 SQL 的提示:切勿在 from
子句中使用逗号。始终使用显式联接。这些比隐式联接更强大(许多人认为它们使查询更易于阅读和维护)。
关于MYSQLWhere语句/子句被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27261296/
我有一个这样的表: +-------------+-------------------+----------------+ |id | column1 | c
从全局 WHERE (type=3) AND WHERE (id BETWEEN 3 和 7) 中选择名称、地址;语法问题。但想法是只从类型 3 列中获取 3 到 7 之间的行。 我删除了 () 之一
首先,我意识到还有其他类似的问题,我已经阅读了其中很多问题,但我无法弄清楚。 我有三个这样的表。 urilist ---------------- rowid | uri 1000 xyz
这个问题已经有答案了: how to trim leading zeros from alphanumeric text in mysql function (8 个回答) 已关闭 5 年前。 MyS
我试图根据与插入对象的匹配从数据库中选择行,但在 WHERE 子句中,我需要条件仅适用于该列值不为空的情况。因此,基本上仅当比较表中的列不为空时,才将列与插入行中的列进行比较。我希望我解释得足够清楚,
我的情况:我的网站将在 Cookie 中查找“记住我” token 和用户 ID。如果 cookie 存在,它将对其进行反哈希处理并查找用户 ID 并比较 token 。带有“WHERE userid
我是一名优秀的程序员,十分优秀!