Thread: shared thinking
View Single Post
Old 11-17-2004, 01:01 PM   #12 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,532
sde is on a distinguished road
mysql query sends an SQL query to the database. SQL ( structured query language ) is a simple way to get the data you want.

here are some examples of useful queries. let's say i had a database of people.

// find all people who's first name starts with 'm'
select * from table where firstname like 'm%'

// find all people who's first name equals mike
select * from table where firstname = 'mike'

// find all people who's first names are mike or john
select * from table where firstname = 'mike' or firstname = 'john'

// delete all people from the database who's first name is mike
delete from table where firstname = 'mike'

// add a new person named john dough to the database
insert into table (firstname,lastname) values('john','dough')

let's say you had a 'lastvisited' field in your database which tracked the last time a user visited .. i could use the following query to get all users who visited this year

select * from table where YEAR(lastvisited)=YEAR(NOW())

you can keep going and get very advanced with sql also. it will allow you to seek out just about any specific data you want. for learning, just stick with simple SELECT, INSERT, UPDATE, and DELETE statements though. that is if you want to

once you do the mysql_query, it returns a set of results. if you do a select * then it will return all fields in the table you are querying. in our case, it would be the equivalent of returning a multidimensional array of people.

i probably didn't make this sound very simple, but once you start using it, you really see the power gained with not even that much of a learning curve.
__________________
Mike
sde is offline   Reply With Quote