Tuesday, October 19, 2010

Groceries

What if you had a list of groceries you wanted to store in a shopping list style list?

How would you do that?

I would define a simple table, like this:



ItemDefault_Qty
Milk1

So then what?? How do you turn that into SQL? Well, that's easy, right?

First you define the table:

create table groceries
(
Item varchar(50)
, Default_Qty int
);

And then you insert some sample data:

insert into groceries (item, default_qty) values ('Milk', 1);