查詢1子句使用時:只有一排被示出,在SQL
select products
from buyde_deal
where displayflag = '1'
and end_date> now()
and start_date < now() limit 1
輸出:
查詢2:
SELECT id,productname ,cat_id ,subcat_id,shortdescription1,shortdescription2,shortdescription3 ,sellingprice,sellpricevat,mrp,regularprice,costprice,sku,qty,pweight,seller_id,shippingcost,color,size,discount
FROM `buyde_product`
WHERE id IN (
select products
from buyde_deal
where displayflag = '1'
and end_date> now()
and start_date < now())
ORDER BY `buyde_product`.`id` "
輸出:
如果我運行第二個查詢,只返回一條記錄。我需要表1中的所有記錄。
的[通過VARCHAR列與IN()中的條件和int值返回所有行部分選擇]可能的複製(http://stackoverflow.com/questions/2064766/ select-by-varchar-column-in-in-in-in-condition-and-int-value-returns-all -r) –