I currently have a code of:
UPDATE graph AS s
JOIN (SELECT Player, (Score) AS newscore
FROM scores
GROUP BY Player) AS d
JOIN (SELECT Player, (Player) AS newplayer
FROM scores
GROUP BY Player) AS e
JOIN (SELECT curdate()) AS q
insert into s ( s.Score, s.Player, s.Date) values ( newplayer, newscore, q);
What I am trying to do is take data from one table and put it into the other.
The first table "graph" is where I want new data put into, it has three fields:
Date Score Player
The second table "scores" is where I want to take the data from, it has many fields but only two are of importance for this:
Player Score
I want to take the data of the current day (Player and Score) and create a new line inside of "graph" using Player Score and CURDATE.
anyone know what I can do to make my code work? or maybe have a better idea for my code?
Thank you.
-edit-
Data in scores table
dem0n123 1220
Mordrah 1236
extcy 1245
What I want the new data in the graph table to look like
dem0n123 1220 2013-12-03
Mordrah 1236 2013-12-03
extcy 1245 2013-12-03
You could use something like this:
CREATE TABLE scores
(`name` varchar(25), `value` int)
;
INSERT INTO scores
(`name`, `value`)
VALUES
('dem0n123', 1220),
('Mordrah', 1236),
('extcy', 1245)
;
CREATE TABLE graph
(`name` varchar(25),
`value` int,
`mydate` DateTime);
insert into graph (name, value, mydate)
select name,value, CURDATE() from scores
select name,value,mydate from graph
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.