Đăng ký ngay

Đăng nhập

Quên mật khẩu

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Đăng nhập

Đăng ký ngay

Lorem ipsum dolor sit amet, consectetur adipiscing elit.Morbi adipiscing gravdio, sit amet suscipit risus ultrices eu.Fusce viverra neque at purus laoreet consequa.Vivamus vulputate posuere nisl quis consequat.

Các câu lệnh truy vấn trong sql server 2008

Các câu lệnh truy vấn trong sql server 2008 mà lập trình viên nào cũng phải biết

1. SELECT:

SELECT * FROM table;

2. WHERE:

SELECT age, name FROM people WHERE age > 10;

3. ORDER:

SELECT name, age FROM people ORDER BY age DESC;

4. JOIN:

SELECT age, name, height FROM people LEFT JOIN heights USING (name);

5. ALIAS:

SELECT A.age FROM people A;

6. UNION:

SELECT age, name FROM customers
UNION 
SELECT age, name FROM staff;

7. INSERT:

INSERT INTO people(name, age) VALUES('Joe', 102);

8. UPDATE:

UPDATE people SET name = ‘Joe’, age = 101;

9.UPSERT:

INSERT INTO people(name, age)
VALUES('Joe', 101)
ON DUPLICATE KEY UPDATE age = 101;

10. DELETE:

DELETE FROM people;

11. CREATE TABLE:

CREATE TABLE people (
  name TEXT,
  age, INTEGER,
  PRIMARY KEY(name)
);

12. ALTER TABLE:

ALTER TABLE people ADD height integer;

13. DROP TABLE:

DROP TABLE people;

Viết bình luận

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>