Question

I'm struggling with a JavaScript function to get data from 2 different queries. If I execute the queries separated in the function, I only get the last result from the first in the second query. I have come to the conclusion that I have to subquery the 2 queries so the function will run properly.

Here are both queries (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) {
Was it helpful?

Solution

i fixed my problem with the current query:

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) {
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top