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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:57:32+00:00 2026-05-28T01:57:32+00:00

I working in a poll script, i have two tables {hs_questions_q}{hs_answers_ans} the first one

  • 0

I working in a poll script, i have two tables {hs_questions_q}{hs_answers_ans} the first one stored the question and the second stored its answers

i used this sql statement to retrieve the data

SELECT * FROM hs_questions_q INNER JOIN hs_answers_ans ON id_q=idq_ans WHERE active_q ='1' and home_q ='1' ORDER BY id_q DESC limit 1

what i was wonder and i can’t deal with in my php code is how that this query returned the last row only from the the question table and answers table, but i need to retrieve the last row from the question table and all rows related to it from the answers table

  • 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-28T01:57:32+00:00Added an answer on May 28, 2026 at 1:57 am

    This will return 1 row per question in the table not as the num rows of answers:

    I assume the structure:

    hs_questions_q (id,desc)

    hs_answers_ans(id,desc)

    SELECT question.desc, group_concat(hs_answers_ans.desc SEPARATOR '#')
    FROM (select * 
              from hs_questions_q 
              where active_q ='1' and home_q ='1' ORDER BY id_q DESC limit 1) question
    INNER JOIN hs_answers_ans ON id_q=idq_ans
    group by question.id
    
    result:
    question1 | Answer1#Answer2#Answer3
    

    Later, you can split it by ‘#’ after retrieving the result on the php side.

    You might get truncated answers if it exceeds the allowed packet size. You can solve it by,

    SET SESSION group_concat_max_len = 6000(any threshold); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been working with David Poll's CollectionPrinter Control and have successfully printed reports which
Working on my first Rails project, I used Ryan Bates' Nifty-Generators to create the
Working on joining up two legacy DB systems into new database where I can
I am new to WCF services. I have been working with WCF for over
I am working on a TcpClient Asynchronous requesting WPF project. In which I have
I am using AlarmManager to poll user location periodically which is working fine- Now
I'm working on a web application that needs to frequently poll the server database
I'm working on a backbone rails application that needs to poll the server to
I am working on a certain application. Its basic structure is as follows: a
I'm trying to get the Poll tutorial working at my Dreamhost account (I don't

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.