Go Back   Webmaster Forum > Development > Programming > PHP
REMOVE the ads below !
Reply
 
LinkBack Thread Tools
  # 1 (permalink)
Old
Junior Geek
Posts: 142
Join Date: Feb 2007
iTrader: (0)
Post PHP 06 : Some sql request - 10-12-2007

Here you can see some SQL request to put into "mysql_query".

Select something :

Code:
SELECT whatyouwant FROM yourtable
Who select in 'yourtable' all ligne
and take 'whatyouwant'

Code:
SELECT whatyouwant FROM yourtable WHERE name='value'
Who select in 'yourtable' all ligne
where name='value' and take 'whatyouwant'

Code:
SELECT whatyouwant FROM yourtable WHERE name='value'
 AND name2='value2'
ORDER BY name DESC
Who select in 'yourtable' all ligne where name='value' AND name2='value2'
and take 'whatyouwant' and then order
by name descendant (DESC), you could
also right ASC for ascendant
AND could be replace by OR, <, >, <>...


Some operations :
You could also count, summarize.... I just present 2 operations but a lot of them exist :

Code:
SELECT COUNT(whatIwant) AS willout FROM mytable
SELECT SUM(whatIwant) AS willout FROM mytable

Update your database :

Code:
UPDATE yourtable SET name='value'
This will change ALL your table and 'name' will take 'value' on each line

Code:
UPDATE yourtable SET name='value' WHERE name2='value2'
This will change all your table where name2='name2',
you could use also AND, OR... as SELECT


Thanks,
Aqua


-------------------
http://www.aquafolie.org

Last edited by aquafolie : 10-12-2007 at 09:49 AM.
Reply With Quote
Reply


Thread Tools



PSD to HTML

vBulletin®, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd. | SEO by vBSEO | Skin developed by vBStyles.com