Click to See Complete Forum and Search --> : mysql - create table with two values


mike12255
01-15-2009, 08:38 PM
I dont know a lot about mysql on itself but i know how to use it with php. So i think what im looking for is called a table.

DELETE FROM example WHERE example2 =$test;

im looking to create example2 with two values only 0,1 ill be using 0 as false and 1 as true. Thanks for help.

debiguana
01-22-2009, 08:05 AM
Mike,

First off, do yourself a favor and go get a book on MySQL. It doesn't hurt to go read all you can about databases in general as well. You will be a better programmer for it.

Second, to create a table in this case, you're looking for
CREATE TABLE example (example2 smallint);

INSERT INTO example (example2) VALUES (0),(1);

There is a database included with MySQL called "test" that would be perfect for this kind of thing (that way you don't need to create a bunch of extra databases for every little test.

What the code above does is create the table with a column called "example2" and then insert two rows with the values 0, and 1 in the table.

Again, this is a very simple example - if you're going to do more extended programming with PHP/MySQL, and writing queries, you really need to go get a book or two, or take a class. But keep up the curiosity, and enjoy the world of databases! :)

-Doug