SELECT Concat(RTrim(vend_name),' (', RTrim(vend_country),')') AS vend_title FROM vendors ORDER BY vend_name;
SELECT prod_id,quantity,item_price,quantity*item_price AS expanded_price FROM orderitems WHERE order_num=20005;
SELECT vend_name,Upper(vend_name) AS vend_name_upcase FROM vendors ORDER BY vend_name;
SELECT DISTINCT vend_country,Left(vend_country,3) AS vend_country_left_3 FROM vendors ORDER BY vend_country;
SELECT DISTINCT vend_country,Right(vend_country,3) AS vend_country_right_3 FROM vendors ORDER BY vend_country;
SELECT DISTINCT vend_country,Substring(vend_country,1,3) AS vend_country_substring_1_3 FROM vendors ORDER BY vend_country;
SELECT cust_name,cust_contact FROM customers WHERE cust_contact ="Y.Lie";
SELECT cust_name,cust_contact FROM customers WHERE Soundex(cust_contact)=Soundex("Y.Lie");
SELECT 3*2;
SELECT RTrim('abc ');
SELECT NOW();
SELECT Left("hello",3); //得到 "hel"
SELECT Right("hello",3); //得到"llo"
SELECT Substring("hello",1,2);//得到"he"
SELECT Locate("ell","hello"); //得到2
SELECT Length("hello'); //得到5
SELECT DISTINCT vend_country,Left(vend_country,3) AS vend_country_left_3 FROM vendors ORDER BY vend_country;
vend_coutnry | vend_country_left_3 |
England | Eng |
France | Fra |
USA | USA |
SELECT DISTINCT vend_country,Right(vend_country,3) AS vend_country_right_3 FROM vendors ORDER BY vend_country;
vend_country | vend_country_right_3 |
England | and |
France | nce |
USA | USA |
SELECT DISTINCT vend_country,Substring(vend_country,2,3) AS vend_country_substring_2_3 FROM vendors ORDER BY vend_country;
vend_country | vend_country_substring_2_3 |
England | ngl |
France | ran |
USA | SA |
SELECT cust_name,cust_contact FROM customers WHERE cust_contact="Y.Lie";
SELECT cust_name,cust_contact FROM customers WHERE Soundex(cust_contact)=Soundex("Y.Lie");
cust_name | cust_contact |
Coyote Inc. | Y Lee |