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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:34:05+00:00 2026-06-18T12:34:05+00:00

I am having following query to fetch message and images from two different table.

  • 0

I am having following query to fetch message and images from two different table.
Here One message can have multiple images

for that i have written following query which is working properly and showing following result

select msg.messageid, msg.message, msg.sentby, msg.adddate, 
p_i.image_id ,p_i.small_pic_path 
from user_messages as msg
LEFT JOIN post_images as p_i
on msg.messageid=p_i.messageid
where msg.messageid='zpx1btrpvpa1360154523078'
order by msg.adddate desc

Output is

 messageid  message  sentby  adddate  image_id  small_pic_path
   1         abc      aa      12/2/12   6          /sdf/sdf
   1         abc      aa      12/2/12   7          /asdf/df
   1         abc      aa      12/2/12   8          /cxd/sxc
   1         abc      aa      12/2/12   9          /zz/szz

Here messageid message sentby adddate is repeating and while displaying in jsp page
showing total 4 different message.

But I want to show 4 imageid and small_pic_path(based on message id) with a relevent message detail

I want to display as

1) Message
sentBy
all small_pic_path of messag id of this message

1) Message
sentBy
all small_pic_path of messag id of this message

2) Message
sentBy
all small_pic_path of messag id of this message

3) Message
sentBy
all small_pic_path of messag id of this message

  • 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-18T12:34:06+00:00Added an answer on June 18, 2026 at 12:34 pm

    Without really understanding your requirements, you write:

    But I want to show 4 imageid and small_pic_path with a single message
    detail

    How do you want to show those records?

    Assuming you mean on the same line, then look into using GROUP_CONCAT:

    SELECT msg.messageid, msg.message, msg.sentby, msg.adddate, 
      group_concat(p_i.image_id separator ';') imageids,
      group_concat(p_i.small_pic_path separator ';') picpaths
    FROM ...
    

    Here’s a SQL Fiddle to demonstrate the results.

    If you are wanting to show the results differently, chances are you should handle that via the UI.

    Best of luck.

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

Sidebar

Related Questions

I have two tables having 1 to 1 relationship. One table called Person and
I want to fetch images from goolge/images again any query. I am using following
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have the following code: (query added) $weight_table = mysql_query (SELECT * FROM .$prefix.weight
I have the following query: $result = mysql_query("SELECT option_value FROM wp_10_options WHERE option_name='homepage'"); $row
Consider the following JPQL query: SELECT foo FROM Foo foo INNER JOIN FETCH foo.bar
I am having comment reply (only till one level) functionality. All comments can have
So im having a problem (obviously). I have the following MySQL table data 7
I am having problems with the following query in Castle ActiveRecord 2.12: var q
I'm trying to run the following query, and I'm having trouble with the wildcard.

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.