1

I have a SQLite3 table that collects data from a gym booking form; all the data goes into one table - Name, Email, Day, Exercise Class, Class Time.

If it is possible, I would like to find a way to get all from Name if Day, Exercise Class & Class Time are equal to a selected value.

I am using Flask so once I can do this the data would then be used to generate a new HTML page (which would be the registration checklist page for the gym tutor).

I am pretty sure this is incorrect, but this is the general idea of what I would like to achieve..

db.execute("SELECT * FROM GymTable WHERE (Day == "Monday", Ex_Class == "BoxFit", Ex_Time == "0745-0845"))
1
  • . . You need to learn basic SQL syntax. There are many resources online and offline to help with that. Commented Apr 29, 2019 at 11:13

3 Answers 3

1

the correct query in this case would be:

db.execute("SELECT * FROM GymTable WHERE Day = 'Monday' and Ex_Class = 'BoxFit' and Ex_Time = '0745-0845'")
Sign up to request clarification or add additional context in comments.

1 Comment

SELECT Name FROM since Sinclair only wants to get names from Name column
1

You may find these two tutorials on the SQL WHERE clause and SQL AND, OR, NOT Operators helpful. Notice first that the equal operator is = instead of ==. This query needs AND between column filters. The WHERE clause should not be enclosed in (). You may find the python sqlite3 doc useful as well.

Comments

1

To better illustrate:

db.execute( "
    SELECT name 
    FROM   gymtable 
    WHERE  day = 'Monday' 
        AND ex_class = 'BoxFit' 
        AND ex_time = '0745-0845' 
");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.