Jump to content

[SOLVED] MySQL query returns no results


bassdog65

Recommended Posts

Ok, I am new to PHP and MySQL, but I have a fairly good understanding of what I am doing, but clearly I am missing something.

 

First, here is what I running:

PHP version 5.2.2

MySQL version 5.0.45

 

I am setting up a basic forum like this, and my database structure looks like this:

5 tables, languages, posts, threads, users, words

posts stores the messages

threads stores the subjects

 

I have entries in every tables, and the PHP portion is fine, and I can enter threads into the forum, but when I go to check the messages, I keep getting no messages in the forum.

 

I ran a MySQL query in phpMyAdmin and it returns no rows, even though they are clearly there, so I think my MySQL syntax is wrong.  Here is the query I am trying to run:

 

SELECT t.subject, p.message, username, DATE_FORMAT( CONVERT_TZ( p.posted_ON,  'UTC',  'America/New_York' ) , '%e-%b-%y %l:%i %p' ) AS posted

FROM threads AS t

LEFT JOIN posts AS p

USING ( thread_id )

INNER JOIN users AS u ON p.user_id = u.user_id

WHERE t.thread_id =4

ORDER BY p.posted_on ASC

 

Every time I run it, it returns:

MySQL returned an empty result set (i.e. zero rows). (Query took 0.0011 sec)

 

Clearly I am missing something, but I am new so I am not spotting my error with the joins.

 

Help please!

Link to comment
https://forums.phpfreaks.com/topic/124668-solved-mysql-query-returns-no-results/
Share on other sites

Ok, that actually worked.  Forgive me for sounding nieve here, but my understanding was that needed to be an inner join.  Without explaining the entire concept of joins to me, is there a simple explanation of what I missed there?

 

Also, I very much appreciate the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.