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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:26:01+00:00 2026-05-16T04:26:01+00:00

I currently need to execute a database query that involves data from three separate

  • 0

I currently need to execute a database query that involves data from three separate tables.
(bases,member,sell_transaction)

The bases table looks like the following

base_id(PK)    name    state

The member table looks like the following

id(PK)    last_name    username   email    first_name

The sell_transaction table has the following schema

transaction_id(PK)    city    
state    
base_id    
date    id   
agentId

NOTE- these tables contain more columns, but they are irrelevant, so I am going to save the time and not write them out.

I am working on a transaction inquiry that involves data from all of these tables. I need to return this data in a TransactionItem that I am populating from these three tables

The TransactionItem as a Pojo looks like the following

public TransactionItem(){

    private String firstName;
    private String lastName;
    private String email;
    private String baseName;
    private String city;
    private String state;
    private Date date;

    public String getFirstName(){
              return firstName;
    }
    public String setFirstName(String firstName){
              this.firstName = firstName;
    }
    ...
    ...///The rest of the getters and setters
    ...
    ...


}

Currently I am doing three separate selects from each table, which is taking longer then I would like. I would image that there is a way I could use a join or nested select statements,etc.

The data and conditions and their corresponding tables are as follows

I need…

first_name, last_name,id from member

I need

name and state from bases where base_id from sell_transaction is equal to base_id from bases

Again there is more that I need, but it is redundant to name them off, The idea should still be clear, I need to query data that is dependent on each other. I am not sure performance wise what is the best performance option. The amount of data that is being traversed could end up being very large or very small(not sure if that matters).

select b.name,b.state, s.city,s.state,s.duty,s.branch,s.date, m.first_name,m.last_name,m.email,m.phone,m.id,s.transaction_id from bases as b, sell_transaction as s, member as m where s.agentId is null and s.username = m.username and b.base_id = s.duty
  • 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-16T04:26:01+00:00Added an answer on May 16, 2026 at 4:26 am
    select first_name, last_name, member.id member_id, bases.name, bases.state
    from bases, sell_transaction, member
    where sell_transaction.base_id = bases.base_id
    and member.id = sell_transaction.agentId;
    

    I am going out on a limb here and guessing that agentID is the connection to member from sell_transaction, but it’s not clear or obvious, and possibly incorrect (unless you clarify your data model).

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

Sidebar

Related Questions

I need a Query that without any changes work on these three different database
I need a mechanism that inserts the data from a newly registered user to
I am currently working on a grails project where I need to execute a
I need to display upcoming events from a database. The problem is when I
Im currently wishing to transfer data from a remote server by capturing printed data
I am currently working on a VB.NET desktop application that uses .mdb (Access) database
I am currently wanting to run a SQL statement that will filter my database
I'm trying to write a query that reports the current database activity. The query
As strange as it sounds I need to slow down a SQL query. Currently
The database I am working with currently does have two tables, one holding the

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.