View Single Post
  #3   Spotlight this post!  
Unread 28-02-2004, 18:16
deltacoder1020's Avatar
deltacoder1020 deltacoder1020 is offline
Computer Guy
AKA: Dav
#1020 (The Indiana Prank Monkeys)
Team Role: Programmer
 
Join Date: Jan 2004
Location: Muncie, Indiana
Posts: 340
deltacoder1020 has a spectacular aura aboutdeltacoder1020 has a spectacular aura about
Send a message via AIM to deltacoder1020
Re: Need Help with SQL

in all of these examples, "..." just means you can have as many fields as you want.

basic insert:
Code:
INSERT INTO table (field1, field2, ...) VALUES ("field1data","field2data",...);
another way to insert:
Code:
INSERT INTO table SET field1="field1data", field2="field2data", ...;
basic retrieval of results:
Code:
SELECT * FROM table;
only retrieve certain fields:
Code:
SELECT field1,field2,... FROM table;
selective retrieval of results:
Code:
SELECT * FROM table WHERE field3="field3value";
ordering the results retrieved:
Code:
SELECT * FROM table ORDER BY field3;
only retrieve the first few results (up to the number specified):
Code:
SELECT * FROM table LIMIT number;
deleting all rows:
Code:
DELETE FROM table;
deleting certain rows:
Code:
DELETE FROM table WHERE field1="field1data";
you can combine just about any of the modifiers above, for example,
Code:
SELECT userid,username FROM users WHERE usergroup="test" ORDER BY userid LIMIT 30;
would give me the username and userid of the first 30 people in the users table whose usergroup is "test", ordered by their userids.
__________________
Team 1020, the Indiana Prank Monkeys (www.team1020.org)

Last edited by deltacoder1020 : 28-02-2004 at 18:21.