1

I have a table called "lists", a table "products" and a table "lists_has_products".

My Table lists:

  • id
  • name
  • imgsrc

My Table products:

  • id
  • name
  • imgsrc
  • categoryid

My Table lists_has_products:

  • listid
  • productid

I want to select all products where the listid is equal to ... .
How can I do this? I already tried this with no result: (I'm working with phonegap)

tx.executeSql("SELECT * FROM PRODUCTS INNER JOIN LISTS_HAS_PRODUCTS ON listid = " + listid, [], onSelectSupermarketsSuccess, onTxError);
4

1 回答 1

1

您的查询应该是

SELECT * 
FROM products p, lists_has_products l
WHERE p.id = l.productid AND listid = "give_a_list_id_here"

只需将其放入代码中-

tx.executeSql("SELECT * FROM products p, lists_has_products l WHERE p.id = l.productid AND listid = ?", [listid] , onSelectSupermarketsSuccess, onTxError);
于 2013-09-05T03:32:14.920 回答