2011-09-12 84 views
0

我正在努力使用JavaScript函數來從2個不同的查詢中獲取數據。如果我執行在函數中分開的查詢,我只會從第二個查詢中的第一個結果中獲得最後一個結果。我得出結論,我必須子查詢2個查詢,以便函數能正常運行。Web數據庫子查詢

這裏有兩種查詢(popt.products_options_id = prodOpId):

tx.executeSql(' 
SELECT DISTINCT 
popt.products_options_id, 
popt.products_options_name 
FROM 
products_options popt, 
products_attributes patrib 
WHERE 
patrib.products_id="1" 
AND 
patrib.options_id = popt.products_options_id 
AND 
popt.language_id = "1" 
ORDER BY 
popt.products_options_name', 
[], function (tx, results) { 


tx.executeSql(' 
SELECT 
pov.products_options_values_id, 
pov.products_options_values_name, 
patrib.options_values_price, 
patrib.price_prefix 
FROM 
products_attributes patrib, 
products_options_values pov 
WHERE 
patrib.products_id = "1" 
AND 
patrib.options_id ='+ prodOpId + ' 
AND 
patrib.options_values_id = pov.products_options_values_id 
AND 
pov.language_id = "1"', 
[], function (tx, results) { 

回答

0

我與當前查詢固定我的問題:

tx.executeSql(' 
SELECT 
popt.products_options_id, 
popt.products_options_name, 
pov.products_options_values_id, 
pov.products_options_values_name, 
patrib.options_values_price, 
patrib.price_prefix 

FROM 
products_options popt, 
products_attributes patrib, 
products_options_values pov 

WHERE 
patrib.products_id="1" 

AND 
patrib.options_id = popt.products_options_id 

AND 
patrib.options_values_id = pov.products_options_values_id 

AND 
popt.language_id = "1" 

ORDER BY 
popt.products_options_name', 

[], function (tx, results) { 
+0

那麼,*爲*的問題? – Makoto