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 8497843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:14:25+00:00 2026-06-11T00:14:25+00:00

I have this query: $result3 = mysql_query(SELECT posts.id, posts.date, posts.title, comments.post, comments.id, comments.date FROM

  • 0

I have this query:

$result3 = mysql_query("SELECT posts.id, posts.date, posts.title, comments.post, comments.id, comments.date FROM posts, comments WHERE posts.id = comments.post")       
or die(mysql_error());  

while($row2 = mysql_fetch_array( $result3 )) {
    echo $row2['title'];
}

The problem is with the posts.id , posts.date and comments.id , comments.date . How can I get out id, date for both tables $row2['....]; I tried $row2['posts.id']; but it didn’t work!

  • 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-06-11T00:14:27+00:00Added an answer on June 11, 2026 at 12:14 am

    Name the column in your query (this is called an column alias) like this:

    SELECT 
        posts.id as postsID, 
        posts.date, 
        posts.title, 
        comments.post, 
        comments.id as CommentsID, 
        comments.date 
    FROM 
        jaut_posts, 
        f1_comments 
    WHERE 
        jaut_posts.id = f1_comments.post
    

    Then you can use:

    echo $row2['postsID'];
    echo $row2['commentsID'];
    

    Edit:

    You may also benefit from this question I wrote and answered which discusses many common SQL queries and requests.

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

Sidebar

Related Questions

Have this query: SELECT HOUR( DATE ) AS hr, COUNT( * ) AS cnt
I have a basic MySQL query: $getFeed = SELECT posts.postID, posts.postTitle, ..... FROM posts
I have this query which groups the results by ORDER#. SELECT ORDER#, MAX(SHIPDATE -
I have this query which returns a result set with Date(column) as nvarchar datatype.
Hey there, why does this code not work? $qry = mysql_query(SELECT performerid,pic0 FROM .$table.
I have this query that should display all posts related to a specific tag
I have the following sample query (MySQL): SELECT * FROM `action` WHERE `customer_id` IN
I have the beginnings of a query: SELECT tf_threads.*, tf_posts.* FROM tf_threads, tf_posts WHERE
i have this code $md_query = SELECT * FROM table ORDER BY id ASC;
I have this mysql query. Any ideas how to order the results in order

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.