メインコンテンツへスキップ

Cross Referencing - ナレッジベース / DPQL - DeskPRO

Cross Referencing

作成者一覧

The FROM Clause


In DPQL you can only specify one table in the FROM clause.

When you're reading through the DPQL field references though you'll notice there are multiple tables

It's often useful to use multiple tables in a single query so in DPQL we have a function called cross referencing  which will allow you to do just that.

If for example we wanted to show a list of tickets and the labels assigned to them we would need to reference both the tickets and the label ticket tables.

We couldn't run 


SELECT tickets.id, labels.label

FROM  tickets, labels


Therefore we'd need to find the linking syntax.


Step 1 - find the reference to the table


Our first step would be to navigate to the tickets table in the documentation.

If you scroll down to the bottom of the tabel you'll see that the last fields referenced are italicized - these are our cross referencing fields.

Here you can see the following for labels:

This means that to link to the Label ticket field we need to use the following syntax:

tickets.labels


Step 2 - Add the field


With cross referencing though once we've linked to the new  table we also need to specify the field name as well (so far we just have two linked tables).

Therefore the correct syntax would be:

 tickets.labels.label


Therefore our full query would be:

 SELECT tickets.id, tickets.labels.label

 FROM tickets

We are specifying only the tickets tabel in the FROM clause but our pulling data from the labels table as well.



 



参考になった 役に立たない

2 人中 1 人がこのページは参考になったと答えました

コメントを追加

コメントを投稿するには、ログインまたは登録が必要です。

パスワードをお忘れですか?