Andyonline
New member
- Local time
- Today, 13:32
- Joined
- Apr 5, 2010
- Messages
- 4
hi everyone, im trying to use constraints in sql queries to control a few things as a create a table, like on one table i want to control the allowed menutypes (lunch,dinner etc) and on another im trying to restrict an amount of money to be between two values.Trouble is i can't get either to work,and i don't know why.Any help greatly appreciated!Im using access 2007.
and the second example of my failure,
All i keep getting are syntax errors but i really can't see the problem, and im new to using sql/access.
Thanks for looking !
Code:
Create Table Menu(
MenuID GUID,
RestaurantID GUID not null,
StartDate Datetime,
EndDate Datetime,
MenuType char (9),
Primary Key (MenuID),
constraint FK_RestaurantID foreign key (RestaurantID) REFERENCES Restaurant (RestaurantID),
constraint chk_MenuType CHECK (MenuType in ("Breakfast","Lunch", "Dinner"))
);
Code:
Create Table MenuItem(
MenuItemID GUID,
MenuID GUID not null,
Name char (25),
Description memo,
ImageLocation char (50),
Price currency,
PreparationTime Integer,
Primary Key (MenuItemID),
constraint FK_MenuID foreign key (MenuID) REFERENCES Menu (MenuID),
constraint chk_price CHECK (Price in (>= 2.99 and <= 24.99))
);
All i keep getting are syntax errors but i really can't see the problem, and im new to using sql/access.
Thanks for looking !