Thursday, December 27, 2012

MySQL Creating Tables - Lessons For Beginners


Create Tables with MYSQL_QUERY
By Stephon Unomon
Google +

 

Now that we’ve selected the database we want to use, we need to put some tables in the database in order to store data. Before that happens, though, you need to think about what kind of data is going in to your tables. I’ll get to why in a moment. Here’s a simple example of table creation with the mysql_query command:

 

<?php mysql_query(“

CREATE TABLE Employees

(employee_id INT,

first_name VARCHAR(50),

last_name VARCHAR(50)”)

?>

You’ll need to define the type of data that is going in to each table field...which is why you’ll need to put some thought into your database before you start creating tables.

 

On the next page lies some common types of data. Remember, if you try to put text (TEXT) into a field that is defined to take numbers (INT), you’re going to get errors! (It’s the square-peg-round-hole scenario!)
 
Do You Want To Get The Most Out Of PHP?
Check Out
The #1 PHP TOOLS

No comments:

Post a Comment