I have an SQL table that stores customer personal data, such as FirstName, LastName, OGCard; OGCard - a field indicating the number of a personal customer card.
Next, I have a table called "Maps" that contains data on ten items that were purchased in the following format: OGCard, Item1ID, ..., Item10ID, Item1Quantity, ..., Item10Quantity
And in the elements of the table I got this structure ItemID, ItemName
I want to get all purchases from CardNumber
I think I should do something like this
SELECT Buyers.FirstName, Items.Name, Cards.Item1Quantity
FROM Buyers
INNER JOIN Cards ON Buyers.OGCard=Cards.OGCard
INNER JOIN Items ON Cards.Item1ID=Items.ItemName
WHERE OGCard=13451
Thus, I see the name of the first element and its quantity. However, I cannot make the same connection to the column Item2ID, etc. Could you offer me some solution?