Hot answers tagged

3

You can't use the aggregated value in WHERE. WHERE is applied to the table data, and the aggregated values are created later. There is the complementary HAVING clause, processed after aggregation. Use that instead. It's placed directly after the GROUP BY part.


1

Consider the potential problems that might result from hardcoding an id and running the query on a different database. Hint: you know the name of the person to look for.


1

I was having the same problem. What worked for me was going back into Django shell and entering the following command. Flight.objects.filter(id=1).delete() Of course if there is more than one flight record you would have to delete each I suppose.


1

Without seeing the description of the table where you're trying to add the foreign key, my best guess is this. FOREIGN KEY(fk_user_id) requires that the parameter here must be a column in the child table. In other words, does/will the child table shares have a column named fk_user_id? Or even user_id? I don't see it in the create table command. Best ...


1

The flask error log (in the console where flask run) should give you all the info you need to troubleshoot and debug. Problem with the first (hover to see spoiler): Problem with the second:


Only top voted, non community-wiki answers of a minimum length are eligible