मैं चालाक 1.0.0 के साथ इस एसक्यूएल निर्माण करने के लिए कोशिश कर रहा हूँ:कैसे चयन खंड में नेस्टेड प्रश्नों लिखने के लिए
select
cat.categoryId,
cat.title,
(
select
count(product.productId)
from
products product
right join products_categories productCategory on productCategory.productId = product.productId
right join categories c on c.categoryId = productCategory.categoryId
where
c.leftValue >= cat.leftValue and
c.rightValue <= cat.rightValue
) as productCount
from
categories cat
where
cat.parentCategoryId = 2;
मेरे सबसे सफल प्रयास (मैं, "मिलती है" भाग गिरा तो यह अधिक पठनीय है):
def subQuery(c: CategoriesTable.type) = (for {
p <- ProductsTable
} yield(p.id.count))
for {
c <- CategoriesTable
if (c.parentId === 2)
} yield(c.id, c.title, (subQuery(c).asColumn))
जो एसक्यूएल सबक्वेरी में कोष्ठक कमी पैदा करता है: जो स्पष्ट रूप से है अमान्य एसक्यूएल
select
x2.categoryId,
x2.title,
select count(x3.productId) from products x3
from
categories x2
where x2.parentCategoryId = 2
कोई विचार कैसे स्लिक को सही ढंग से इन कोष्ठक डालता है? या शायद इसे हासिल करने का एक अलग तरीका है?
आप अपने प्रयासों के साथ-साथ पोस्ट कर सकते हैं:
परिणाम है? –
मैंने पोस्ट किया है जो मुझे अब तक मिला है – wassertim
यह मुझे क्वेरी कंपाइलर में एक बग/निरीक्षण की तरह दिखता है। शायद आपको एक बग रिपोर्ट दर्ज करनी चाहिए। –