0

我的 Google-Fu 在这方面很弱,所以也许你们都可以帮忙。

如果要选择多个列,可以执行...

SELECT 'something' as userName, 'fooBar' as typicalSaying

你会得到:

+----------------+-----------------+
|    userName    |   typicalSaying |
+----------------+-----------------+
|   something    |    fooBar       |
+----------------+-----------------+

但是,如何对行进行上述操作?

例如:

SELECT someLine, effy.text from table
LEFT JOIN (SELECT 'a' as text UNION 'b' UNION 'c') as effy 

编辑: 要得到像..

+----------------+--------------+
|    someLine    |   effy.text  |
+----------------+--------------+
|   entryA       |    a         |
|   entryA       |    b         |
|   entryA       |    c         |
+----------------+--------------+
4

1 回答 1

1

你几乎在那里:

SELECT someLine, effy.text
FROM table
LEFT JOIN (
  SELECT 'a' as text
  UNION ALL
  SELECT 'b'
  UNION ALL
  SELECT 'c'
) as effy 
于 2012-07-09T19:29:59.617 回答