简体   繁体   English

WHERE 子句中使用的列的 SELECT 顺序

[英]Order of SELECT for column used in WHERE clause

on question 13 of SQLZoo ( https://sqlzoo.net/wiki/SELECT_names ), I get an error if I change the order of the select from "SELECT capital, name" to "SELECT name, capital".在 SQLZoo ( https://sqlzoo.net/wiki/SELECT_names ) 的问题 13 中,如果我将选择的顺序从“SELECT capital, name”更改为“SELECT name, capital”,则会出现错误。 Why does it matter?为什么这有关系?

SELECT capital, name
FROM world
WHERE capital LIKE concat('%', name , '%')

在此处输入图片说明

Hi jja, To clarify your question, the order of column names that you select do not matter here.嗨 jja,为了澄清您的问题,您选择的列名的顺序在这里无关紧要。 It just picks the column name that you gave first and displays that column results first.它只是选择您首先提供的列名称并首先显示该列结果。

For example, The below select statement displays capital column followed by name.例如,下面的 select 语句显示大写列后跟名称。

SELECT capital, name FROM world

Similarly, the below SQL Query returns name column followed by capital.同样,下面的 SQL 查询返回 name 列后跟大写。

SELECT name, capital FROM world

I ran the query you have submitted here and did not get any error.我运行了您在此处提交的查询,但没有出现任何错误。 Try again and if you still encounter any error, share the error so that we can help.再试一次,如果您仍然遇到任何错误,请分享错误以便我们提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM