You have a database that has a few tables in it and you want to add some values in those tables (more exactly in the fields of the tables). So what do you do?
You can:
- go to PhpMyadmin and just select the database, table and insert the values.
- you can LEARN how to write the SQL code so that the values will be entered in the proper place.
So, let's do that :).
In order to insert something in the Mysql database you need to use the INSERT INTO command. After that you write the name of the table like so: `table_name` and then you start enumerating the fields between ( ) like so: (`field1`, `field2`, `field3`) next you add the values by writing VALUES and then again the values that need to be stored in the previous fields, IN THAT EXACT ORDER!!!! like so: ('value1', 'value2', 'value3') and then you end with a ;.
This is how the full code is supposed to look like:
INSERT INTO `table_name` (`field1`, `field2`, `field3`) VALUES ('value'`, 'value2', 'value3');
you notice that the fields are in one type of brackets and values are in another type.
like this: `field1` and 'value1'. only values must be in ' ' .Everything else is in ` ` :)
Hope It helped,
Cy21
Sunday, February 25, 2007
Insert into Mysql Database - SQL commands
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment