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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:29:44+00:00 2026-05-15T19:29:44+00:00

This query works: SELECT Article.id, Article.post_time, Article.post_locked, Article.comments_locked, Article.title, IF(CHAR_LENGTH(Article.content)>2000, RPAD(LEFT(Article.content,2000),2003,’.’), Article.content) as content,

  • 0

This query works:

SELECT Article.id, 
       Article.post_time, 
       Article.post_locked, 
       Article.comments_locked, Article.title,  
       IF(CHAR_LENGTH(Article.content)>2000, 
          RPAD(LEFT(Article.content,2000),2003,'.'), 
          Article.content) as content, 
       Article.tags, Category.*, 
       User.id, User.user_name, 
       Comment.comment_count 
  FROM `articles` as `Article` 
LEFT JOIN `categories` as `Category` ON `Article`.`category_id` = `Category`.`id` 
LEFT JOIN `users` as `User` ON `Article`.`user_id` = `User`.`id` 
LEFT OUTER JOIN (SELECT article_id, count(*) comment_count FROM `comments`) as `Comment` ON `Article`.id = `Comment`.article_id 
    WHERE '1'='1' 
 ORDER BY `Article`.`id` DESC

But when I loop through the resultset to assign the table name along with the field using ‘mysql_field_table’, the ‘content’ returns a table name of nothing, while all others have their correct table:

Array ( 
    [0] => Article 
    [1] => Article 
    [2] => Article 
    [3] => Article 
    [4] => Article 
    [5] => 
    [6] => Article 
    [7] => Category 
    [8] => Category 
    [9] => User 
    [10] => User 
    [11] => Comment )

using

for ($i = 0; $i < $numOfFields; ++$i) {
   array_push($table,mysql_field_table($this->_result, $i));
   array_push($field,mysql_field_name($this->_result, $i));
}

Anyone ever try to do this? Have a solution? I want to return less data from my DB in my query. Or is it less intensive (on mysql, memory, cpu) to simply select all content and truncate the content via PHP? I thought returning less from DB would be better.

Thanks a bunch!!

Peace.

EDIT

to clear up, this is the result, you will see why it isnt what I want:

Array ( 
    [0] => Array ( 
        [Article] => Array ( 
            [id] => 8 
            [post_time] => 1278606312 
            [post_locked] => 0 
            [comments_locked] => 0 
            [title] => Article 8
            [tags] => test ) 
        [] => Array ( 
            [content] => my content for Article  ) 
        [Category] => Array ( 
            [id] => 2 
            [name] => cat2 ) 
        [User] => Array ( 
            [id] => 3 
            [user_name] => user3 ) 
        [Comment] => Array ( 
            [comment_count] => 1 ) 
    ) 
   [1] => Array ( 
        [Article] => Array ( 
            [id] => 7 
etc...
  • 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-15T19:29:44+00:00Added an answer on May 15, 2026 at 7:29 pm
    while ($row = mysql_fetch_row($this->_result)) {
        $prev_table;
        for ($i = 0;$i < $numOfFields; ++$i) {
            if ($table[$i] == "") {
                $tempResults[$prev_table][$field[$i]] = $row[$i];
            }else {
                $tempResults[$table[$i]][$field[$i]] = $row[$i];    
            }
            $prev_table = $table[$i];
        }
    }
    

    Oh well, mysql couldnt do what I wanted. I added the prev_table to take the one before 😉

    Thanks to everyone for the help.

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

Sidebar

Related Questions

Good day guys, I don't know... why does not this query works: SELECT article.topic,
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
This query works: item = db.GqlQuery(SELECT * FROM Item WHERE CSIN = 13)[0] although
This query works fine for me: $query = SELECT p.topnode_id, p.param_key, p.param_value FROM tbl_params
I've got this query that works ok, select * from Materia where Cursar_Cursada=0 and
I'm having this Mysql query, It works: SELECT nom ,prenom ,(SELECT GROUP_CONCAT(category_en) FROM (SELECT
i've been using the following query: select LEN(columnname) as columnmame from dbo.amu_datastaging This works,
I have this elementary query: SELECT d.description, o.code FROM order_positions AS o LEFT JOIN
I have a query that looks like this: SELECT article FROM table1 ORDER BY
This SQL query was generated by Microsoft Access 2003, and works fine when run,

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.