SQL父子查询 - 关系在两个表中定义(SQL Parent Child query - relation is defined in two tables)
我知道这里有类似的问题,但我找不到他的特殊情况,所以我想问你,我希望你会告诉我如何做到这一点更好。
我有这个
SQL Fiddle
。
我有两张桌子:CATEGORIES (ID, NAME, PARENT_ID, SORT_ORDER)
和
CATEGORY_ITEMS (ID, NAME, CATEGORY_ID, SORT_ORDER)
这两个表在某种程度上是我的真实数据库模式的简历(我没有可能改变它)。 在我的真实数据库模式中,这些类别可以定义基于特定日期时间值有效的集合。 我想知道是否可以通过一个查询返回如下所示的结果。
| NAME | |-------------------| |Category 1 | |Item 1 Category 1 | |Item 2 Category 1 | |Category 1.1 | |Item 1 Category 1.1| |Item 2 Category 1.1| |Category 1.2 | | Category 1.2.1 | | Category 2 | |Item 1 Category 2 | |Item 2 Category 2 | | Category 2.1 | | Category 2.2 | | Category 3 | | Category 3.1 | | Category 3.2 |
在SQL Fiddle中,你可以看到我的工作到现在为止。 我认为我可以通过将树结构从
CATEGORIES
转换为游标来获得我想要的东西,并且对于每个记录我应该从CATEGORY_ITEMS
获取它的记录,但我想知道是否有可能在没有游标的情况下执行它。 我承认我不擅长SQL,但我想要做得更好,这就是我问这个问题的原因。I know that there are similar questions here but I couldn't find my particular situation in them, so I want to ask you and I hope that you will advise me on how it's better to do it.
I have this
SQL Fiddle
.
I have two tables:CATEGORIES (ID, NAME, PARENT_ID, SORT_ORDER)
And
CATEGORY_ITEMS (ID, NAME, CATEGORY_ID, SORT_ORDER)
These two tables are somehow the resume of my real database schema (I don't have the possibility to change it). In my real database schema, these categories can define sets that are valid based on certain datetime values. I would like to know if it is possible to return results like below with one query.
| NAME | |-------------------| |Category 1 | |Item 1 Category 1 | |Item 2 Category 1 | |Category 1.1 | |Item 1 Category 1.1| |Item 2 Category 1.1| |Category 1.2 | | Category 1.2.1 | | Category 2 | |Item 1 Category 2 | |Item 2 Category 2 | | Category 2.1 | | Category 2.2 | | Category 3 | | Category 3.1 | | Category 3.2 |
In the SQL Fiddle you can see my work until now. I think that I can obtain what I want by getting the tree structure from
CATEGORIES
into a cursor and for each record I should get it's records fromCATEGORY_ITEMS
, but I was wondering if there is a possibility to do it without a cursor. I admit that I am not to good at SQL but I am trying to be better so that's why I am asking this question.
原文:https://stackoverflow.com/questions/30421237
最满意答案
要调整侧边栏的大小,您需要做的就是单击并拖动:
遗憾的是,无法在用户首选项,项目或当前主题中设置“默认”大小。
To resize the sidebar, all you need to do is click and drag:
There is no way to set a "default" size in your user preferences, project, or current theme, unfortunately.
相关问答
更多-
Sublime Text 3如何更改文件边栏的字体大小?(Sublime Text 3 how to change the font size of the file sidebar?)[2022-06-27]
答案是省略方括号 ,在这种情况下,从头开始创建文件。 要概述,对于没有Default.sublime-theme文件(实际上是默认配置)的ST3用户,最简单的过程是: 导航到Sublime文本 - >首选项 - >浏览包 打开User目录 创建一个名为Default.sublime-theme的文件(如果您使用默认主题,否则使用主题名称,例如Material-Theme-Darker.sublime-theme ),其中包含以下内容(根据需要修改font.size ): [ { "c ... -
您正在寻找一个Sublime UI主题 ,它修改了Sublime的用户界面(例如:侧栏)。 它与颜色主题/方案不同,它仅修改了Sublime窗口的代码部分。 我测试了很多UI主题,我最喜欢的是主题 - 苏打水 。 您可以使用Sublime的软件包控制进行安装。 要启用它,请转到首选项>>设置 - 用户并添加以下行: "theme": "Soda Dark 3.sublime-theme", 这是我的崇高文本3与Soda Dark UI主题和暮光默认颜色方案的打印屏幕: The most recent ve ...
-
Sublime Text 2如何更改文件边栏的字体大小?(Sublime Text 2 how to change the font size of the file sidebar?)[2023-01-18]
选择Preferences / Browse Packages… ,然后转到Theme - Default目录。 使用编辑器打开Default.sublime-theme并搜索sidebar_label字符串。 你应该找到类似的东西: { "class": "sidebar_label", "color": [0, 0, 0], "font.bold": false } 你可以在这里添加你喜欢的字体大小: { "class": "sidebar_label", "c ... -
您必须在“升华文本”窗口中添加一个文件夹才能通过侧边栏导航。 转到File -> Open Folder...并选择您想要导航的最高目录。 You have to add a folder to the Sublime Text window in order to navigate via the sidebar. Go to File -> Open Folder... and select the highest directory you want to be able to navigate.
-
要调整侧边栏的大小,您需要做的就是单击并拖动: 遗憾的是,无法在用户首选项,项目或当前主题中设置“默认”大小。 To resize the sidebar, all you need to do is click and drag: There is no way to set a "default" size in your user preferences, project, or current theme, unfortunately.
-
您可以通过编辑sidebar_label类的font.face和font.size属性来影响侧边栏字体外观。 { "class": "sidebar_label", "color": [116, 140, 161], "font.size": 11.0, "font.face": "Consolas" }, 可能有更多的font子属性; 但是你可能必须通过探索现有主题来找到它们,因为目前暂时不存在官方的sublime-theme文档。 我建议在研究主题相关问题时使用以下主题 ...
-
如果我理解正确,您希望侧边栏扩展到您使用Goto Anything找到的某个文件。 为此,您可以安装SyncedSideBar包。 SyncedSideBar Sublime Text 2插件,用于将项目侧边栏(文件夹视图)与当前活动文件同步。 Sublime Text 2仅突出显示已扩展的文件。 此插件突出显示所有文件(例如,使用cmd + p打开) 。 If I understand you correctly, you want to have the sidebar expand to some f ...
-
你可以在Sublime内改变它。 转到Preferences - > Key Bindings - User并粘贴此: [ { "keys": ["f10"], "command": "toggle_side_bar" } ] 如果您已经有一堆自定义键绑定,请省略方括号。 { "keys": ["f10"], "command": "toggle_side_bar" } You can change that within Sublime. Go to Preferences -> Key Bi ...
-
我遇到了同样的问题:安装在我的Windows 7机器上的ST3无法在侧栏和选项卡中正确显示带有中文字符的文件名。 我在中文网站 "dpi_scale": 1.0找到了此解决方案 :只需在用户首选项文件中添加"dpi_scale": 1.0 ,然后重新启动ST3。 这个对我有用! I had the same problem: The ST3 installed in my Windows 7 machine could not display file names with Chinese characte ...
-
我非常了解侧边栏宽度是每个项目,即存储在
.sublime-workspace文件中。 相关的钥匙是 "side_bar_visible": true, "side_bar_width": 260.0, 因此,您可以使用您喜欢的宽度值编辑工作区文件。 Well I know so much that the sidebar width is per-project, i.e. stored in the .sublime-workspace file. The relev ...