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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:06:35+00:00 2026-06-17T19:06:35+00:00

I have two table user and contact, each user can have multiple contacts I

  • 0

I have two table user and contact, each user can have multiple contacts
I want to draw a graph (camembert) with JFreeChart(java library) to present the number of contacts that has each user
I tested :

select u.name, sum(c) from user u, contact c

but I have

unknown column c in field list

here are the structures of tables :

utilisateur = idutilisateur, identifiant, motdepasse, nom, prenom

contact = idcontact, …………, idutilisateur

How can I achieve that,

and also, please give me links to tutorials for learning to make queries like that because always I have this problem and I find only basic tutorials
thank you in advance

  • 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-17T19:06:36+00:00Added an answer on June 17, 2026 at 7:06 pm

    You need to reference the column of the table that you’re trying to count, not just the table itself.

    if you try:

    select u.name, count(c.ID) 
    from user u, contact c
    

    You can count all records that have a value in the ID field. If this is a primary key, then all records should have this field. Note the change from sum to count.

    This won’t fully solve your problem. You also have to let sql know that the two tables are related by joining:

    JOIN contact
    ON user.ID=contact.userID
    

    Put this after the from user u instead of , contact c

    For a good start to learning sql, try here: http://www.w3schools.com/sql/default.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 user and email. One user can have multiple emails so
I have two tables, in which one user can have several contacts: User(UserId, UserName)
I have two tables in my database: user and media_contact . The media_contact table
I have two tables user table user_id | name | 1 | peter |
I have two table views, when user clicks one cell of the first, second
I have two tables, a user table and a application table: User id username
I have two tables. One user table and one table in which results are
I have two models, user and group. I also have a joining table groups_users.
I have two tables like this: TABLE user( id CHAR(100) text TEXT ) TABLE
I have two tables: Relationships (ID, UserID, Type, Contact ID) Contacts (ID, Name, Address)

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.