Zack-Taylor / CandyApi

0 stars 2 forks source link

Candy Tracking #6

Closed gseals closed 4 years ago

gseals commented 4 years ago
gseals commented 4 years ago

update your own databases with these lines:


UPDATE Stash
SET Stash.CandyId = 6
WHERE Stash.StashId = 6

INSERT INTO Candy VALUES('Reese', 'Hershey', 5, '2020-05-19', 0, 1)
INSERT INTO Candy VALUES('Reese', 'Hershey', 5, '2020-05-19', 1, 1)
INSERT INTO Candy VALUES('Reese', 'Hershey', 5, '2020-05-19', 0, 1)
INSERT INTO Candy VALUES('Reese', 'Hershey', 5, '2020-05-19', 0, 1)
gseals commented 4 years ago

this query returns all candies by owner that have not been eaten


SELECT
    Candy.CandyId,
    Candy.[Name],
        Candy.Manufacturer,
    Candy.FlavorId,
    Candy.DateCollected,
    Candy.Ate,
    Candy.StashId
FROM Candy
JOIN Stash ON Stash.StashId = Candy.StashId
JOIN [User] ON [User].Uid = Stash.UserId
WHERE Candy.Ate = 1 AND [User].uid = 1
ORDER BY Candy.DateCollected, Candy.StashId