Link to home
Start Free TrialLog in
Avatar of pc-buddy
pc-buddy

asked on

Php Sql Query

Hi,

I'm trying to pull all records for a certain Id from the Db, this is my query

SELECT * FROM child_session WHERE child_id=293 And end_date > 2016-10-13 And start_date < 2016-10-13

Open in new window


But no results are returned.

What is wrong please

Thank Simon
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Try quoting your dates - otherwise what does your data look like?
Avatar of pc-buddy
pc-buddy

ASKER

start_date is 2016-09-02
end_date is 2016-12-15

Thanks
That's not a data record - can you post a script with the table definition and data.
Hi,

Sorry, picture attached of DB,

I need to pull only session that are active and I've noticed the end dates of some are 0000-00-00

$sessionsq = "SELECT * FROM child_session WHERE child_id='".$id."' And end_date > '".$today."' And start_date < '".$today."'";	
$childsessions = mysql_query( $sessionsq, $conn );[embed=file 1122094]

Open in new window


Thanks Simon
query.jpg
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for all your help
You are welcome.