Jump to content

sql statement delimma


babydoll

Recommended Posts

hi y'allam a newbie and am having crisis with my sql stmnt.the backend of my app is mysql and the sql statement i want to work is

$sql =select topic_title, topics.mod_id, topic_creator, topics.role, topics.post_timestamp, post_creator, posts.role, posts.post_timestamp from topics, posts where topics.topic_ic=posts.topic_id, topics.mod_id=$mod , posts.post_timestamp between '$startdate and '$enddate

am trying to generate a report from 2 tables. where the user will enter the search criteria and time frame given by $mod,$startdate and $enddate respectivelyPLEASE HELP :)

Link to comment
Share on other sites

hii tried what u said removed the ' from the date vars and echoed the whole sql stmnt.which is

select topics.topic_id, posts.topic_id, topic_title, mod_id, topic_creator, topic_role, post_timestamp from topics, posts where topics.topic_id=posts.topic_id , mod_id="COA122" and post_timestamp between 2006-08-07 and 2006-08-19

it doesnt give me any errors, however whn i removed the tablename.fieldx thing it showed part of the out put with some noticed of undefined vars but i need to logically get output from the tables.is there anywhere that i can get precise mysql sql syntax so that i try that please. :)

Link to comment
Share on other sites

Not sure what the problem is but maybe you could have a go at troubleshooting to see where it fails.First of all make your query to be SELECT.... all the way up to, but not including the WHERE or BETWEEN. See what the output is.If it works try it again but this time add the WHERE topics.topic_id=posts.topic_id. If that works then add the next bit (ie by adding topics.mod_id=$mod). And so on. If it all works up to the point you add the date fields then you know that's where the problem lies.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...