[Prev] Thread [Next]  |  [Prev] Date [Next]

[sqlite] Help with CHECK Constraint Pete Sat Feb 18 17:00:17 2012

I;m trying to figure out just what I can do within the limits of a CHECK
constraint.  Is it possible to check the value of the column containing the
CHECK constraint for presence in a column in a different table.  For
example, assuming the CHECK constraint is on TableA.Col1, is it possible to
check if the value of Col1 exists in a column in a different table? Perhaps
something like "SELECT count(rowid) FROM TableB WHERE
TableA.Col1=TableB.Col1".  I've been trying this and getting syntax errors
but not sure if I am getting the SELECT statement wrong or if it's just not
possible to do this in a CHECK statement and perhaps I need to use a
trigger instead.


sqlite-users mailing list