Design your database such that you have a Student table and within that table you store their University Card Number and their ID Number (I would possibly have had an intersection table but I'm keeping this simple)
Have another table that records who has bought a meal. That table should contain the ID number used, a value equating to the Primary key of the Student table (i.e. a Foreign key back to the Student table), and presumably some details about the meal purchased.
To search whether or not a student has already had a meal search for something like
SELECT StudentPK
FROM Student S
INNER JOIN MealsBought M ON S.IDNO = M.CardNo OR S.UniNO = M.CardNo;
Or if you want to do it by passing the card used for the meal then use
SELECT *
FROM Student S
WHERE S.IDNO = @IDNO OR S.UniNo = @IDNO;
(As I said in my comment yesterday)
Some other advice:
- Don't use default names for controls. Get into the habit of giving them meaningful names the minute you place them on your canvas/form/page. Who knows what
Button1
is meant to be??
- Only post relevant code in your questions and learn to use the
code
helper in the question editor. Nobody wants to scroll through a lot of meaningless text
- Always, always include some sample data and your expected results. For database questions including the table schemas is usually useful - but only the relevant ones.
Finally, take note of the comment from Richard - we do this as volunteers in our spare time, some of us do not take kindly to impatient students. Put the effort in and we will try our best, but it's your homework, not ours.