Step 8: Some Basic MySQL
Okay, now that I've posted the way MySQL codes worked, I think we should move on to the codes.
Basically, I only use a few of the MySQL scripts as shown below:
1) INSERT
The way this script works is simple. Here's the syntax:
I hope you'd notice that when you use MySQL, it works where:
- The user logs in
- The first layer, the first group of gathered data, is the database
- The database contain tables
- One user can have several databases, and each database can contain several tables.
2) SELECT
This syntax is used to fetch data from a table.
To select contents of all columns, the column_name field is filled with an asterisk (*) sign. This syntax can have an additional order,
With it, the syntax will be
3) UPDATE
This syntax is used to update a table content, may it be specific or all at once.
This syntax could also use a WHERE addition.
Those were some basic MySQL codes. To execute them, the PHP code is
Basically, I only use a few of the MySQL scripts as shown below:
1) INSERT
The way this script works is simple. Here's the syntax:
INSERT INTO('table_name') VALUES('data_to_be_added1', 'data_to_be_added2');
I hope you'd notice that when you use MySQL, it works where:
- The user logs in
- The first layer, the first group of gathered data, is the database
- The database contain tables
- One user can have several databases, and each database can contain several tables.
2) SELECT
This syntax is used to fetch data from a table.
SELECT column_name FROM table_name;
To select contents of all columns, the column_name field is filled with an asterisk (*) sign. This syntax can have an additional order,
WHERE
to select a specific row content.With it, the syntax will be
SELECT column_name FROM table_name WHERE='content_specification';
.3) UPDATE
This syntax is used to update a table content, may it be specific or all at once.
UPDATE table_name SET column_name='new_content', column_name2='new_content2';
This syntax could also use a WHERE addition.
UPDATE table_name SET column_name='new_content' WHERE='content_specification';
Those were some basic MySQL codes. To execute them, the PHP code is
mysql_query($query,$mysql_id);
where the $mysql_id
variable is a fetchback result of the order mysql_connect()
. The connection had a connection ID, and it's what the $mysql_id
variable keeps.