Hello,... i have a mysql database called theMember and a table called news, inside news i have field called newsDateInsert. field date is integer(8), which 2 digits first are Date, nest 2 digits are Month and last 4 digits are Year,... And, i have a variable $month which taken from a form. my problem is,... i want to retrieve all data, which based on month value on newsDate field which taken from $month with this query.... $strSQL1 = "SELECT * FROM theMember where SUBSTRING ('newsDateInsert',3,2) like '$month' order by newsDateInsert desc limit $limit, 10 "; but i have the error message like this: You have an error in your SQL syntax near '(newsDateInsert,3,2) like '11' order by newsDateInsert desc limit 0, 10 ' at line 1 Does anyone here could help my problem,....which part of this query that has a mistake Thank you very very very much Best Regards
Suppose you will have to remove the space between SUBSTRING and the bracket, i.e. SUBSTRING(newsDateInsert,3,2)
If you want to order by newsDateInsert desc, you should structure it as yyyymmdd to correct the date order. Also the way you are using it, '01012007' will become 1012007 when saved as Integer. newsDateInsert should be Varchar to save it as '01012007'
hello, i already changed the query script like this, i delete the space after SUBSTRING $strSQL1 = "SELECT * FROM theMember where SUBSTRING('newsDateInsert',3,2) like '$month' order by newsDateInsert desc limit $limit, 10 "; it still is not work, but no error report. it seem the "newsDate Insert", not refer to the field in data base. how is that?