MySQL Head Banger :@ !!! (1 Viewer)

BlueIshDan

☠
Local time
Today, 18:30
Joined
May 15, 2014
Messages
1,122
Hello Follow Nerdlings :D

I'm about to bash my head :banghead: off of every surface in sight if I don't figure out what I'm missing...

This query:
Code:
$query = 'SELECT comments.id, comments.comment, users.first_name, users.last_name ' . 
         'FROM comments left join users on users.id = comments.user_id ' . 
         'WHERE comments.post_id = ' . $post_id . ' [COLOR="Red"]AND comments.date_deleted IS NULL[/COLOR] ' .
         'ORDER BY comments.post_id DESC';

Is still returning records with date_deleted fields that have values in them... WHY!? NO ERRORS AND CORRECT SYNTAX!!!

I'm going to cry here soon lol... the little things in life they say :mad:
 

stopher

AWF VIP
Local time
Today, 22:30
Joined
Feb 1, 2006
Messages
2,395
What data type is comments.date_deleted? What values are you getting that you would expect to be Null?
 
Last edited:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 22:30
Joined
Sep 12, 2006
Messages
15,651
out of interest I don't understand the periods either side of $post_id

. $post_id .

they should be ampersands

& $post_id &
 

BlueIshDan

☠
Local time
Today, 18:30
Joined
May 15, 2014
Messages
1,122
What data type is comments.date_deleted? What values are you getting that you would expect to be Null?

The data type is datetime. The result is returning all comments respective to the post. But it is not filtering for the date_deleted condition.


To Dave:

Sorry, I forgot to mention that this code snippet is written in PHP. :p
 

stopher

AWF VIP
Local time
Today, 22:30
Joined
Feb 1, 2006
Messages
2,395
What happens when you include comments.date_deleted in the Select. What values are you seeing?

Are you also seeing Null values?
 

BlueIshDan

☠
Local time
Today, 18:30
Joined
May 15, 2014
Messages
1,122
 

Attachments

  • Capture.jpg
    Capture.jpg
    79.5 KB · Views: 98

Gasman

Enthusiastic Amateur
Local time
Today, 22:30
Joined
Sep 21, 2011
Messages
14,260
What do you get if you output $query ?
 

BlueIshDan

☠
Local time
Today, 18:30
Joined
May 15, 2014
Messages
1,122
"SELECT comments.id, comments.comment, users.first_name, users.last_name FROM comments left join users on users.id = comments.user_id WHERE comments.post_id = 34 AND comments.date_deleted IS NULL ORDER BY comments.post_id DESC"
 

BlueIshDan

☠
Local time
Today, 18:30
Joined
May 15, 2014
Messages
1,122
All good people!
It miraculously worked lmao!

I've never seen PHP results cache before... weird.

Thanks for the help! :D
 

Users who are viewing this thread

Top Bottom