Posted by Shattered_Mynd on 10/14/67 11:32
I'm building an app in PHP MySQL and am trying to think of the best way to
implement this:
The problem is I want to collect data entered into a form when 3 of these
entries match I want to move ONE instance of it to another table. The idea
I've had is to construct a count query like this:
SELECT
table1.Name,
COUNT(Name) AS NumOccurrences
FROM
table1
GROUP BY
table1.Name
HAVING
(COUNT(Name) > 2)
The result form this query shows all of the entries that have been inserted
into the table more than three times.
My Question is how can I take this result and put it into another table
(i.e. table2) and delete all instances of it in table1? This should happen
only if this query puts out a result? If not (so if there are less than two
matching entries in the table) then the Name is added into table1 as
normal.
Any help or assistance you guys can give me with this will be highly
appreciated.
TIA
Navigation:
[Reply to this message]
|