Sunday, May 6, 2012

Mysql | SQL → basic

SQL. key word

SELECT        

→ retrieves data from one or more tables


Sintaxe SELECT * FROM nameTable
Ex: SELECT name , old  FROM person


FROM 
→ tables involved in the query. Required in each SELECT
Sintaxe →  SELECT * FROM nameTable
Ex: SELECT name , old  FROM person


WHERE        
→ Selection criterion that determines the rows to be retrieved.
Sintaxe → SELECT coll1,coll2 FROM person WHERE  criterion
Ex: SELECT name, old FROM person WHERE old > '18'


GROUP BY   
→ Criteria for grouping rows


ORDER BY   
→ Criteria for odenar lines
Sintaxe → SELECT coll1,coll2 FROM person ORDER BY   coll ASC|DESC
Ex: SELECT name,old FROM person ORDER BY  old 
Ex: SELECT name,old FROM person ORDER BY  old  ASC 
Ex: SELECT name,old FROM person ORDER BY  old  DESC


INNER JOIN 
→ Merge multiple rows of tables
Sintaxe → SELECT coll1,coll2 FROM table1 INNER JOIN table2 ON table1.coll1 = table2.coll2 
Ex: SELECT name,old FROM person INNER JOIN person2 ON person.name = person2.name
Ex: SELECT name,old FROM person INNER JOIN person2 ON person.name = person2.name ORDER BY person.old


INSERT        
→ Insert row in a table specifies
Sintaxe → INSERT INTO nameTable (coll1,coll2,coll3,...) VALUES(val1,val2,val3,...)


UPDATE      
 → update row in a table specifies
Sintaxe UPDATE nameTable SET nameColl1 = value,  nameColl2 = value WHERE criterion
Ex: UPDATE person SET name = ComandLine WHERE name = Blog


DELETE       
 →Delete row in a table specifies
Sintaxe →  DELETE FROM nameTable WHERE criterion
Ex: DELETE FROM person WHERE name = 'Silva'  END old = '22'  


Share this page. 

0 comentários:

Post a Comment