Skip to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MySQL in query optellen

Ik heb een tabel met de volgende informatie erin: naam, score, spel.

Een naam kan vaker voorkomen in de tabel, maar slechts één keer per spel. Alles staat in 1 tabel. Is het mogelijk om te zoeken naar alle records met een bepaalde naam, om vervolgens alle scores bij elkaar op te tellen en deze weer te geven in een tabel?

Featured Replies

SELECT `naam`, SUM(`score`), `spel`
FROM `tabel`
GROUP BY `naam`

GROUP BY zorgt ervoor dat je de records die dezelfde naam hebben, groepeert. De SUM-functie telt de gehele inhoud uit de scorekolom op.

  • Author

SELECT `naam`, SUM(`score`)
FROM `scores`
GROUP BY `naam`

Dit is nu mijn query, alleen de kolom van 'score' is leeg. Moet ik score niet apart aangeven bij SELECT?

  • Author
CREATE TABLE IF NOT EXISTS `scores` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `naam` varchar(250) NOT NULL,
 `score` int(25) NOT NULL,
 `spel` varchar(250) NOT NULL,
 UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=113 ;

Hij werkt bij mij gewoon hoor?

Edit: ik snap 'm al denk ik. Verander in je PHP eens $row['score'] (o.i.d.) naar $row['SUM(`score`)'] of zet in je query achter SUM(`score`) AS `score`

  • Author

Helemaal top, hij werkt! :tu: Bedankt. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.