I have a simple question about the SQL of an UPDATE query. I found something very close to what I want to know here: MySQL: Count occurrences of distinct values
But.. it's not an update query. Here's the example of what I want to do:
In one table (let's call the table "data"), I want to make an UPDATE query. Here’s what the table looks like:
Id color count
1 blue 0
2 blue 0
3 red 0
4 red 0
5 blue 0
6 white 0
Now, [id] is the auto-incremental key for this example, [color] is a TEXT field. [count] is a number
What I want, is for the count to be UPDATED so that it tells how many instances a [color] occurs. After the UPDATE query runs, the table would look like this:
Id color count
1 blue 3
2 blue 3
3 red 2
4 red 2
5 blue 3
6 white 1
Looks pretty simple, but I've messed with the DCOUNT and COUNT commands, and I'm probably missing something very easy, but still... no joy. All the help I've seen only only deals with SELECT queries, but I will definitely need this query to update the [count] field.
Thanks in advance!