0 votes
in Databases by (2k points)
i want to find data between two dates and display results in table.

code: ps = DbConnection.cn.prepareStatement("SELECT Bill_no, Date, Cust_Name, Contact_No, Reg_No, Model, CC, QTY, Engine_No, Chasis_No, Payment_Mode, Grand_Total FROM stock WHERE date = '$from' and '$to' ");

code does not work.

1 Answer

0 votes
by (1.9k points)

You should use the between operator:

SELECT Bill_no, Date, Cust_Name, Contact_No, Reg_No, Model, CC, QTY, Engine_No, Chasis_No, Payment_Mode, Grand_Total  
FROM   stock 
WHERE date BETWEEN '$from' AND '$to'

 

...