简体   繁体   中英

SQL - Using the results of subquery in SELECT in the SELECT

Example:

SELECT
    (
        ...
    ) AS imageName,
    (
        ...
    ) AS imageURL,
    CONCAT(imageName, ' ', imageURL)

How could I achieve this?

You can do the following but watch out the tables' aliases:

   SELECT
     T.imageName, T.imageURL
     CONCAT(imageName, ' ', imageURL)
   FROM 
   (
       SELECT
      (
        ...
       ) AS imageName,
       (
        ...
      ) AS imageURL
       FROM ... AS innerT
   ) T

您可以在CONCAT内完成所有操作,如下所示:

select CONCAT(( select ... ), ' ', ( select ... )) 

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