Jump to content

Search the Community

Showing results for tags 'different tables'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi everyone, I've been wrapping my head around this problem and I was wondering if you could help me. I have the following three tables with example data: results_patterns =========================== name | medal -------- | ------------ James | Gold James | Silver James | Silver Paul | Gold Sam | Bronze Sarah | Silver results_sparring =========================== name | medal -------- | ------------ James | Bronze James | Bronze James | Bronze Paul | Silver Sam | Gold Sarah | Silver results_patterns =========================== name | medal -------- | ------------ James | Silver James | Silver James | Gold Paul | Gold Sam | Bronze Sarah | Silver There are other columns in the tables such as date, age, category etc but these are not necessary. The idea being that there can be duplicate medals and names in each table (due to different competition dates) I'm trying to get a medal count for each individual person, and produce an sql statement to get a result like this: results =========================== name | gold | silver | bronze ---------|----------|-----------|----------- James | 2 | 4 | 3 Paul | 2 | 1 | 0 Sam | 1 | 0 | 2 Sarah | 0 | 3 | 0 I hope it's clear what I'm after; I'll happily explain more if required. I've tried UNION ALL three tables for WHERE 'Gold' medals. I wanted to count how many gold medals per person but I failed at this stage. I was then going to perhaps JOINT LEFT this results with the same for each Silver and Bronze. But I have no idea how to go about it. Any help would be greatly appreciated as I'm a noob with MySQL. Thanks very much
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.