如何在子查询中使用sql select中的字段?

时间:2019-04-25 13:47:36

标签: mysql string integer

我正在尝试使用来自主查询的子查询中的字段进行选择查询。 问题是,子查询中名为“ t.code ”的字段必须像字符串一样使用,并用单引号引起来。

SELECT t.id, t.code, t.name,
    (select date from positions pt where pt.code = 't.code' order by date asc limit 1) as position
    FROM trips t

0 个答案:

没有答案