Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3396262
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:23:12+00:00 2026-05-18T04:23:12+00:00

I’m using this MySQL query, called by MySQL: SELECT tf_posts.*, tf_threads.thread_id FROM tf_threads LEFT

  • 0

I’m using this MySQL query, called by MySQL:

SELECT tf_posts.*, tf_threads.thread_id FROM tf_threads LEFT JOIN tf_posts ON tf_threads.thread_id=54

When I use mysql_fetch_array I get an array full of each field, but the actual values for the fields are acting very strangely indeed…

Any numeric or date fields are returned just fine; I can use them in the array. Any text fields, however, are empty. The array returned is shown below in it’s raw form:

Array
(
    [0] => 
    [id] => 
    [1] => 
    [thread_id] => 820515612
    [2] => 
    [poster_id] => 
    [3] => 
    [title] => 
    [4] => 
    [body] => 
    [5] => 
    [date] => 
    [6] => 
    [edit_date] => 
    [7] => 
    [edited] => 
    [8] => 
    [draft] => 
    [9] => 
    [spam] => 
    [10] => 820515612
)

Ignore the numerical indexes here – I’m interested in the named ones. The fields body and title are text fields (CHAR()), and are, obviously, not displaying when they should be.

What have I done wrong or missed here? Is it because I’m using CHAR()? I strongly doubt it but I’m not great with MySQL.

EDIT:

The idea of this query is to select all threads from one table (tf_threads), and take the first post under that thread from another table (tf_posts) and use the posts title field as the title for the thread.

Thanks,

James

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:23:12+00:00Added an answer on May 18, 2026 at 4:23 am

    Your join clause doesn’t make sense to me. It looks like you’re trying to get all posts for thread_id 54, but you’re not joining the two tables, and you’re not getting any data from the tf_threads table other than thread_id, which I presume is also present in your tf_posts table. Why not just use a WHERE clause:

    SELECT * FROM tf_posts WHERE thread_id = 54
    

    If this doesn’t work, please post your table descriptions and what the query should return.

    To answer your edit, you need to actually join the tables then, and with an INNER JOIN if you only want one post – a LEFT JOIN would give you all posts for each thread.

    SELECT tf_threads.*, tf_posts.* FROM tf_threads INNER JOIN tf_posts
       ON tf_threads.thread_id = tf_posts.thread_id
       ORDER BY tf_posts.date ASC
    

    This should give you all threads and the first post (as determined by the date column) for each thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.