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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:08:22+00:00 2026-06-06T14:08:22+00:00

i have this java code: ArrayList<MessageMap> ids = getNewMail(UserID, type, maxIdMessage); Message[] message =

  • 0

i have this java code:

ArrayList<MessageMap> ids = getNewMail(UserID, type, maxIdMessage);
Message[] message = new Message[ids.size()];
if(ids.size()>0){
   ResultSet rs;
   int j =0;
   for(MappaMessaggi i : ids){
      pstmt = conn.prepareStatement("SELECT * FROM Messaggi WHERE MessageID = ?");
      pstmt.setInt(1, i.getMessageID());
      rs = pstmt.executeQuery();
      rs.next();
      .
      .
      .
   }

where getNewMail is:

public synchronized ArrayList<MessageMap> getNewMail(int UserID,int type,int max){
   ArrayList<MessageMap> map = new ArrayList<MessageMap>();
   try {
      pstmt = conn.prepareStatement("SELECT * FROM MessageMap WHERE UserID = ? AND TipoID = ? AND MessageID > ?");
      .
      .//fill arraylist with resultSet 
      .
}

I know that is possible to do the same with just one query but i don’t know how.. can someone open my eyes? 🙂 thanks!!!

EDIT: i try:

SELECT i.*
FROM Messaggi AS i
INNER JOIN MessageMap AS p i.MessageID = p.MessageID
WHERE p.MessageID = 1 AND p.UserID = 1 AND p.TipoID = 2

BUT I RETRIEVE:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'i.MessageID = p.MessageID WHERE p.MessageID = 1 AND p.UserID = 1 AND p.TipoID = ' at line 3
  • 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-06T14:08:23+00:00Added an answer on June 6, 2026 at 2:08 pm

    Try this:

    SELECT i.*, p.*
    FROM Messaggi i
    INNER JOIN MessageMap p ON i.MessageID = p.MessageID
    WHERE i.MessageID = ? AND p.UserID = ? AND p.TipoID = ?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have the following piece of java code ArrayList<Double> myList = new Double[100];
I have this code: package com.problemio; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
i have this code: static ArrayList<Integer> output_list = new ArrayList<Integer>(); static ArrayList<Integer> pair_list =
I have this code package com.cerbertek; import java.util.ArrayList; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory;
i have this code: public class Test{ arrayList<String> list = new ArrayList<String>(); String[][] temp_list;
I have this code snippet import java.util.ArrayList; import java.util.List; public class AssertTest { public
This is my Java code: List<Object> objects = new ArrayList(); // Assign values to
Say I have the following java code: Object myObj = new ArrayList(); List myList
I have this Java code, and I want to do the same thing in
I have this Java code which is used for JSF pagination: public List<ActiveSessionObj> list(int

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.