【发布时间】:2012-11-08 05:00:39
【问题描述】:
我有两张桌子:items 和 orders
items
--------------
id (int) | type_1 (int) | type_2 (int)|
orders
--------------
id (int) | transaction_type enum ('type_1', 'type_2')
基本上,我想做以下事情:
select (select transaction_type from orders where id=1) from items;
所以,问题是select transaction_type from orders where id=1返回的string,不能转换成列名。
【问题讨论】:
-
运行该查询时遇到的错误是什么?我似乎得到了正确的回答,但我可能误解了这个问题:)
-
@RocketDonkey 它返回字符串“type_1”的数量(按项目中的行数)
-
明白了,我的错 - 发布了一些可能有用的东西(抱歉,如果我再次误解了)。
标签: mysql