我有两张表 treeview_items 和 file_up
treeview_items
file_up
一个查询(不是我写的)
SELECT *
FROM treeview_items
UNION
SELECT id + (select max(id) from treeview_items), name,
path as text,dir_id as parent_id
FROM file_up
现在如何修改此查询,以便 file_up 表中的 id 也会在查询结果中列出?我尝试过一些东西但仍然卡住了!
当前输出和预期输出,此处列名 id from file_up 仅用于演示。
答案 0 :(得分:0)
不确定我是否得到了你所说的内容,但是你在寻找这样的东西吗?
SELECT *, WhateverID = NULL
FROM treeview_items
UNION
SELECT id + (select max(id) from treeview_items), name,
path as text,dir_id as parent_id, WhateverID
FROM file_up