Dynadot โ€” .com Registration $8.99

SQL help please.

Spaceship Spaceship
Watch

Coolprogram

Established Member
Impact
7
I would like an example of how I would start off an SQL code. please help me with this. I have been wanting to know for quite some time so please help me.
Thanks,
-CP
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
PHP:
<?php
$sql = "SELECT * FROM table_name WHERE field='something'";
/* Above is a very common sql query used in verified that username is equal to the username in the database. */

$sql = "INSERT INTO table_name (name) VALUES('name')";
/* Above is a insert data into a database query */

$sql = "UPDATE table_name SET name='somethingelse'";
/* Above is a update value in database query */

$sql = "DELETE FROM table_name WHERE name='something'";
/* Above is a delete all the values where name is equal to something */

Following all these are
mysql_query($sql);
// That command processes the sql query
?>

Good Luck

- Steve
 
1
•••
Thaks a lot man I needed to know that.I only have 1 more question for you, that is how do i make a database??
-CP
 
0
•••
It would be something like

PHP:
<?php

$sql = "CREATE TABLE example(
id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)";
/* Above creates a table with AUTO INCREMENT (Or addes one everytime you add result) for field id. aswell as creates field name, and age. */

?>

I suggest you install PHPMyAdmin. It would make the creating of tables just that much easyer.

- Steve
 
0
•••
to create a database, it's simply
PHP:
<?php
mysql_query('CREATE DATABASE databasename');
?>
 
0
•••
Just a note most users do not have the correct permissions to create a database. The creation of a database on hosting packages is ussually carried out using their control panel rather than a query you personally execute.
 
0
•••
okay thank guys, I have 1 more question though...How would I do connect to MySQL??
Thanks,
-CP
 
Last edited:
0
•••
mysql_connect(<database host>, <database user name>, <database password>);

-Bob
 
0
•••
Thanks man, I really needed to know that. 'cause now I can connect some stuff to a data base. TY TY.
-CP
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back