简体   繁体   中英

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". 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. 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 capital, name FROM world

Similarly, the below SQL Query returns name column followed by capital.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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