boon_chong Posted February 16, 2007 Share Posted February 16, 2007 I'd like to query only the month of stockmovement.date, but when i use stockmovement.month(date) the error come out. Somebody please help me to figure out. Thx. $query = "select distinct employee.itemNo,employee.itemDesc,employee.date, employee.outlet,stockmovement.barcode,stockmovement.quantity,stockmovement.date from employee,stockmovement where employee.itemNo =stockmovement.barcode group by employee.itemNo"; Quote Link to comment Share on other sites More sharing options...
jcbarr Posted February 16, 2007 Share Posted February 16, 2007 Might be better to post this on the SQL board, unless you are getting some sort of specific error. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 I'd like to query only the month of stockmovement.date, but when i use stockmovement.month(date) the error come out. Somebody please help me to figure out. thanks. $query = "select distinct employee.itemNo,employee.itemDesc,employee.date, employee.outlet,stockmovement.barcode,stockmovement.quantity,stockmovement.date from employee,stockmovement where employee.itemNo =stockmovement.barcode group by employee.itemNo"; I'll just clean it up to focus only on the SQL. SELECT DISTINCT employee.itemNo, employee.itemDesc, employee.date, employee.outlet, stockmovement.barcode, stockmovement.quantity, stockmovement.date FROM employee, stockmovement WHERE employee.itemNo = stockmovement.barcode, GROUP BY employee.itemNo Now, I'm not entirely sure what you want. Could you please rephrase? These are two of my interpretations: 1) To retreive the records where the stockmovement.date = certain month? 2) You want to convert stockmovement.date into something you can work with in your program logic (ie. via the date object)? If #1, yea, as jcbarr said, the SQL forums'd find you plenty more answers. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 16, 2007 Share Posted February 16, 2007 Perhaps if you told us what the error was? My guess is you want to do: SELECT DISTINCT employee.itemNo, employee.itemDesc, employee.date, employee.outlet, stockmovement.barcode, stockmovement.quantity, stockmovement.date FROM employee, stockmovement WHERE employee.itemNo = stockmovement.barcode AND MONTH(stockmovement.date) = $month_number GROUP BY employee.itemNo Where $month_number is an integer between 1 and 12, inclusive. @8ball, You have an error in your MySQL query. Check the manual for the correct syntax to use near "WHERE employee.itemNo = stockmovement.barcode, GROUP BY" ;^] Quote Link to comment Share on other sites More sharing options...
Guest Posted February 16, 2007 Share Posted February 16, 2007 @8ball, You have an error in your MySQL query. Check the manual for the correct syntax to use near "WHERE employee.itemNo = stockmovement.barcode, GROUP BY" ;^] Oops! Oh well, I just copied and pasted his and cleaned it up. That comma went right by me! Good eye! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.