Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement returns data only sometimes

Status
Not open for further replies.

shamrox

Programmer
Sep 27, 2001
81
US
Ok, I have a database with 2 tables linked on ID. I run my query and it only returns data sometimes, depending on what ID I ask for. All the records have data in them, so I can't figure why I only get a return sometimes. Here is my statement. Can anyone shed some light?
Thanks.


$result = @mysql_query("SELECT ctitle, DATE_FORMAT(cDate, '%M %d, %Y') as ctextdate , ctime, course_intro.completion, course_intro.backcolor, course_intro.border_color,course_intro.outline, course.cid, course_intro.introduction, clocation FROM course
LEFT JOIN course_intro on course_intro.cid=course.cid WHERE course.cid='".$cid."'
AND clocale LIKE '&quot;.$locale.&quot;'AND CURDATE() < cdate ORDER BY cdate&quot;);
 
Ok...
the first thing that comes to me is: are the id -fields auto incremental, because for me, that would seem to be a bad idea. Not that it should cause the problem you're describing.

Personally I prefer having a 'target' column on the table that is joined to an another table. (The value is naturally determined by the id of the row it is linked to.)

An other thing could be typo's but I assume you have checked for that. For the third you could change the statements on which the selection is made. Testing if removing some of the criterias helps e.g. trying to remove the LIKE -part...

I don't know if this helps you with solving the problem, or if it's just a waste of your time :/
Hope you solve it

//hZ
 
Starting at the top, I'd say drop the @ - this prevents any error messages from being displayed.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
I'll ask the dumb question.

The $cid value which returns no info -- that value does appear in the cid column of course, right? ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top