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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:28:45+00:00 2026-05-28T03:28:45+00:00

I am trying to run a query using JOIN. so, I wrote the below:

  • 0

I am trying to run a query using JOIN.
so, I wrote the below:

SELECT * FROM (SELECT trade_date, trade_time, price, contract_name 
               FROM test 
               WHERE contract_name="Z10" 
               AND trade_date="2010-12-01" 
               AND trade_time="0900") 
AS A JOIN (SELECT trade_date, trade_time, price, contract_name 
           FROM test 
           WHERE contract_name="H11" 
           AND trade_date="2010-12-01" 
           AND trade_time="0900") 
AS B ON (A.trade_date=B.trade_date 
AND A.trade_time=B.trade_time);

it runs fine, except it returns a large number of rows:

+------------+------------+-------------+---------------+------------+------------+-------------+---------------+
172025 rows in set (0.31 sec)

so I ran the below 2 queries individually to check how many max rows I should get, and from the below it should not exceed 1000.

mysql> select count(*) 
       from test 
       where contract_name="Z10" 
       and trade_date="2010-12-01" 
       and trade_time="0900";
+----------+
| count(*) |
+----------+
| 983 |
+----------+
1 row in set (0.02 sec)

mysql> select count(*) 
       from test 
       where contract_name="H11" 
       and trade_date="2010-12-01" 
       and trade_time="0900";
+----------+
| count(*) |
+----------+
| 175 |
+----------+

Can anyone suggest how I edit my JOIN to get the union of the 2 contracts on the selected date and time.

  • 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-28T03:28:46+00:00Added an answer on May 28, 2026 at 3:28 am

    You in fact don’t need to do the join if you are getting result from same table. You can do this:

    select count(*)
    from test
    where contract_name in ("H11","z10")
      and trade_date="2010-12-01"
      and trade_time="0900";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the following MySQL query: SELECT * FROM user u JOIN
Original Query I'm trying to rewrite: SELECT Table1.* FROM Table1 INNER JOIN Table2 ON
I'm trying to run a query from ADO.NET using SQL Server 2008R2. I'm using
I am trying to run a query on a SQLite database that INNER JOIN
I am trying to calculate the time it takes a query to run using
I'm trying to run a simple LDAP query using directory services in .Net. DirectoryEntry
The Query is as follows: SELECT v2.video_id FROM `VideoTags` AS v1 JOIN `VideoTags` AS
I am using SQL Server 2008, and trying to run the following query in
I am trying get the values using SP.The query is below. create proc [dbo].[GetOrdersByUserID11]
I'm using the MySql.Data dll from MySql and trying to execute a query to

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.