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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:06:38+00:00 2026-05-23T23:06:38+00:00

I have two tables in the same database with matching id’s. The first table

  • 0

I have two tables in the same database with matching id’s.

The first table is accounts

id - account_access - name - email - city - state - etc...  
1 - 1 - Mark - mark@mark.com - Seattle - WA - blah,blah,blah  
2 - 1 - Dave - dave@dave.com - Portland - OR - blah,blah,blah  
3 - 0 - Jake - jake@jake.com - San Francisco - CA - blah,blah,blah  
4 - 1 - Julie - julie@julie.com - Los Andeles - CA - blah,blah,blah

The second table is members

 id - status - score - IQ  
 1 - 4 - 9000 - 108  
 2 - 5 - 8000 - 90  
 3 - 5 - 1000 - 25 (Disclaimer: Any relation to real people is purely coincidental)  
 4 - 5 - 5000 - 60

Since Jake wasn’t very bright, he has zero access to the account.

What I want to know is how many people with account_access (1) have status (5), or how many people with status (5) have access.
I’m not familiar with how to word the SELECT statement comparing two tables, i would like to know number of rows and then to also retrieve the data to display.

  • 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-23T23:06:39+00:00Added an answer on May 23, 2026 at 11:06 pm

    What you want to do is a left join.

    SELECT count(*)
    FROM Accounts
    LEFT JOIN members
    ON Accounts.id = members.id
    WHERE status = 5
    AND account_access = 1
    

    Additional info on Left Joins: http://www.w3schools.com/sql/sql_join_left.asp

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

Sidebar

Related Questions

I have two tables in my database: NEWS table with columns: id - the
I have two tables in my SQL database: Company: ID (autoincrement) name address ...
I have two tables within the same database. On one I can use the
I have a two same tables.Database mysql. How can I compare two tables? Table1,Table2
I have two tables in different databases on the same database server. Both the
I have two tables in my legacy database Purchases Id int(PK) name varchar(50) MasterAccount
I have two tables with the same columns, and I need to copy one
I have two tables with the same columns tbl_source (ID, Title) tbl_dest (ID, Title)
Problem: a table of coordinate lat/lngs. Two rows can potentially have the same coordinate.
We have two Tables: Document: id, title, document_type_id, showon_id DocumentType: id, name Relationship: DocumentType

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.