1 / 8

MySQL

MySQL. SQL for MySQL (I). Salim Mail : salim.sucipto@gmail.com Phone : 0815-188-2384 YM : talim_bansal Blog : http://salimsribasuki.wordpress.com. 1. Summary. Retrieving Data Using the SQL SELECT Statement Restricting and Sorting Data Using Single-Row Functions to Customize Output.

Download Presentation

MySQL

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. MySQL SQL for MySQL (I) Salim Mail : salim.sucipto@gmail.com Phone : 0815-188-2384 YM : talim_bansal Blog : http://salimsribasuki.wordpress.com MySQL - Query 1

  2. Summary • Retrieving Data Using the SQL SELECT Statement • Restricting and Sorting Data • Using Single-Row Functions to Customize Output MySQL - Query

  3. SELECT COMMON PATTERN SELECT <*, Field 1,….., Field n, Aggregate Function> FROM < Table Name> WHERE <Condition> AND/OR <If any additional condition> GROUP BY <Field 1,……, Field n> HAVING <Condition> ORDER BY <Field1,…., Field n> MySQL - Query

  4. Retrieving Data Using the SQL SELECT Statement • Select All Columns • Syntax : SELECT * FROM <Table Name>; • Sample : SELECT * FROM ti3k_item_master • Select Specific Columns • Syntax : SELECT <Column Name, Column Name, Column Name,……Column Name> • FROM <Table Name>; • Sample : SELECT item_id, item_name, item_uom • FROM ti3k_item_master; • Use Arithmetic Operators MySQL - Query

  5. Retrieving Data Using the SQL SELECT Statement • Understand Operator Precedence • Precedence defines the order that Oracle uses when evaluating different operators in the same expression. Every operator has a predefined precedence. Oracle evaluates operators with a higher precedence before it evaluates operators with a lower precedence. Operators with equal precedence will be evaluated from left to right MySQL - Query

  6. Restricting and Sorting Data • Write queries that contain a WHERE clause to limit the output retrieved • Syntax : Select <Column Name,……Column Name> • From <Table Name> • Where <Column Name or Logical Phrase>; • Sample : SELECT item_id, item_name, item_uom • FROM ti3k_item_master • Where item_uom ='Set'; • Write queries that contain an ORDER BY clause sort the output of a SELECT statement (Ascending or Descending) • Sample : Select * from ti3k_item_master • Order by item_uom asc; • Sample : Select * from ti3k_item_master • Order by item_id desc; MySQL - Query

  7. Restricting and Sorting Data List the comparison operators and logical operators that are used in a WHERE clause MySQL - Query

  8. Sample SELECT with WHERE using Comparison operators Exercise: select item_uom “UOM” from ti3k_item_master where item_code =‘DRL10’; select item_id, item_code, item_name, item_uom, remark From ti3k_item_master where item_id > 50 And item_uom =‘Each’; select * from ti3k_item_master where item_uom in (‘Sax’,’Set’) Order by item_uom, item_id; select * from ti3k_item_master where remark is null Or created_by = ‘Salim’; select * from ti3k_item_master where item_id between 10 and 20; MySQL - Query

More Related