Here's a quick something for you to chew on. I created the table for you and did the inserts of your sample data even though the table structures you will learn more in time.
As for creating column names for tables, try to never use reserved words or even functions that might cause confusion down the road... such in this case "Class", "Day". When you are coding, you will see the reserved words typically appear in a blue syntax color. If you have then when creating your table, think again for a better name for the column.
As for VFP column names. If the table is NOT part of a "Database Container", then the column name limit is only 10 characters (so I changed your "Lesson_Name" to just "LessonName").
I am doing this sample with simple SQL querying. The difference in querying you see in VFP vs other sql databases is relatively minimal. The one big thing is that in VFP, a semi-colon is an indication that the command CONTINUES on the next line. In SQL, the semi-colon is typically indicating the END of a command.
*/ Sample... create the tables and insert the values
SET SAFETY OFF
CLOSE TABLES ALL
CREATE TABLE Classes;
( Class C(3),;
Day N(1),;
Lessons C(7) )
INSERT INTO Classes ( Class, Day, Lessons );
VALUES ( "IX", 1, "MEP" )
INSERT INTO Classes ( Class, Day, Lessons );
VALUES ( "X", 2, "MBE" )
INSERT INTO Classes ( Class, Day, Lessons );
VALUES ( "XI", 3, "FCM" )
*/ Create the next table and insert their records
CREATE TABLE Lessons ;
( Lesson C(1),;
LessonName C(10) )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "M", "Math" )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "E", "English" )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "B", "Biology" )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "F", "French" )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "P", "Physics" )
INSERT INTO Lessons ( Lesson, LessonName );
VALUES ( "C", "Chemistry" )
*/ Prepare a look and keep asking until a user hits the escape key (ASCII 27)
DO WHILE LASTKEY() <> 27
*/ prepare a value for data entry of the class
SomeClass = " "
@ 1,1 say "Enter a value for a class (escape or leave blank to exit):" get SomeClass picture "!!!"
READ
IF EMPTY( SomeClass )
EXIT
ENDIF
*/ Query the classes table for the value entered
USE IN SELECT( "FoundClass" )
SELECT Class, Day, Lessons;
FROM Classes;
WHERE Class = SomeClass;
INTO CURSOR FoundClass READWRITE
*/ Did we find the class?
IF RECCOUNT( "FoundClass" ) = 0
MESSAGEBOX( "Sorry, class was not found" )
ELSE
*/ Now, get all lessons associated with the class.
USE IN SELECT( "FoundLessons" )
SELECT Lesson, LessonName;
FROM Lessons;
WHERE Lesson $ FoundClass.Lessons;
INTO CURSOR FoundLessons READWRITE
IF RECCOUNT( "FoundLessons" ) = 0
MESSAGEBOX( "Sorry, no lessons found for the class" )
ELSE
CLEAR
?
?
?
? "Class: " + FoundClass.Class, ;
" Day: ", FoundClass.Day, ;
" Lessons: " + FoundClass.Lessons
? "Lessons:"
SELECT FoundLessons
SCAN
? FoundLessons.LessonName
ENDSCAN
ENDIF
ENDIF
USE IN SELECT( "FoundClass" )
USE IN SELECT( "FoundLessons" )
ENDDO
CLEAR