-1
什麼,我試圖做的是從多個表中獲取數據,假設我有我的查詢結果如下: 交叉引用多個表
的數字列ticket_item_type代表某個表。例如,2代表tbl_company,3代表tbl_lease。然後細節表示該表中某個記錄的ID。
假設我想使用ticket_item_type和details來獲取這些記錄的標題。是否可以嵌入到結果中?或者我應該爲每個單獨查詢。
我知道JOIN,但我只是單桌嗎?
下面是上面的圖片我的MySQL查詢:
SELECT *
FROM
(SELECT *
FROM ticket_items
WHERE hs_customer = 1
AND ticket IN
(SELECT id
FROM tickets
WHERE hs_customer='1'
AND ticket_status = 'dispatch_reviewed')
AND ticket IN
(SELECT ticket
FROM ticket_items
WHERE ticket_item_type = 5
AND details = '159')) AS TB1
WHERE ticket_item_type IN (3,
2,
8)
它的工作原理!謝謝! –