Is it possible for a subquery to return two values?

為{幸葍}努か 提交于 2019-12-01 17:13:06

If you use the subquery in the FROM clause rather than the field list, then you can treat the output as a table and refer to the separate columns.

You are just selecting numbers as results so couldn't you just do:

SELECT 1, COUNT(*), MAX(*) FROM test_table WHERE test=123

Not possible

mysql> select 1, (select 2, 3) from dual;
ERROR 1241 (21000): Operand should contain 1 column(s)

If you are dealing with two tables and you what the results in one line, you should preform a join.

Hmm, it depends on what exactly you want to do with the data, you can join two tables using JOIN syntax, and one of the tables can actually be a subquery. I think that is probably what you want.

I'm not even user what your current query will do..

Documentation: http://dev.mysql.com/doc/refman/5.0/en/join.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!