I've been trying to set up a small database with HeidiSQL but I've stumbled across a problem. I want to add in a column in a certain table that counts the amount of columns in another table containing a certain value. I've tried it by setting a default value, entering a custom value looking like this
SELECT COUNT(LidID) AS AantalSchepen FROM SCHIP WHERE SCHIP.LidID=LID.LidID
Whereas LidID is the name of the column I want to count the number of rows, containing the same value in table SCHIP as in table LID. The value of LidID is the primary key of table LID, and therefor logically the foreign key in table SCHIP.
However, when I enter this statement in the custom default value field, it tells me the default value is invalid. Is what I'm doing completely impossible, or is my SQL statement flawed?
Edit: The purpose of the database is to be the source of info shown in a table on a website. As I've read in previous responses, what I'm trying to do here is simply impossible, so a different solution would be... ?