1 / 9

DWA 2

DWA 2. Lesson 04. MySQL – osnovni SQL izrazi. INSERT UPDATE DELETE SELECT (najvažniji, najkorišteniji, ali i najsloženiji izraz). 1. INSERT – unos podataka.

jacob-byers
Télécharger la présentation

DWA 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DWA 2 Lesson 04

  2. MySQL – osnovni SQL izrazi • INSERT • UPDATE • DELETE • SELECT (najvažniji, najkorišteniji, ali i najsloženiji izraz)

  3. 1. INSERT – unos podataka • INSERT [INTO] table [(column1, column2, column3, ...)] VALUES (value1, value2, value3, ...), (value4, value5, value6, ...); • insert into customers (name, city) values ('Melissa Jones', 'Nar Nar Goon North');

  4. 2. UPDATE • UPDATE [LOW_PRIORITY] [IGNORE] table_reference SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... [WHERE where_condition] [ORDER BY ...] [LIMIT row_count] • update customers set address = '250 Olsens Road‘ where customerid = 4;

  5. 3. DELETE • DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [WHERE where_condition] [ORDER BY ...] [LIMIT row_count] • DELETE FROM somelog WHERE user = 'jcole' ORDER BY timestamp_column LIMIT 1;

  6. 4. SELECT • SELECT [ALL | DISTINCT | DISTINCTROW ] [HIGH_PRIORITY] [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] [SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS] select_expr [, select_expr ...] [FROM table_references [WHERE where_condition] [GROUP BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [PROCEDURE procedure_name(argument_list)] [INTO OUTFILE 'file_name' export_options | INTO DUMPFILE 'file_name' | INTO @var_name [, @var_name]] [FOR UPDATE | LOCK IN SHARE MODE]] • http://dev.mysql.com/doc/refman/4.1/en/select.html

  7. 4. SELECT PRIMJERI • SELECT * FROM books; • $row = $r->fetch_array() // echo $row[0] • SELECT id,name FROM books; • $row = $r->fetch_assoc() // echo $row[‘id’] • SELECT id,name,price FROM books ORDER BY price DESC;

  8. 4. SELECT PRIMJERI • SELECT AVG(price) FROM books; • SELECT COUNT(*) AS broj_knjiga FROM books; • // echo $row[‘broj_knjiga’] • SELECT CONCAT(f_name,’, ‘,l_name) AS ime_prez FROM people;

  9. 4. SELECT - SPAJANJA • SELECT t1.name, t2.salary FROM employee AS t1, info AS t2 WHERE t1.name = t2.name; • SELECT college, region AS r, seed AS s FROM tournament ORDER BY r, s;

More Related