You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT col1, col2 FROM table
WHERE condition
ORDER BY col DESCLIMIT10 OFFSET 20;
SELECT t1.*, t2.nameFROM orders t1
LEFT JOIN users t2 ONt1.user_id=t2.id;
SELECT dept, COUNT(*) n, AVG(salary) avg
FROM employees
WHERE active =1GROUP BY dept
HAVING n >5;
SELECT*FROM (
SELECT*, ROW_NUMBER() OVER (PARTITION BY dept ORDER BY salary DESC) rn
FROM employees
) WHERE rn =1;
修改
INSERT INTO users (name, email) VALUES ('张三', 'zhang@example.com');
UPDATE users SET status ='active'WHERE id =1;
DELETEFROM logs WHERE created_at <'2025-01-01';
CREATEINDEXidx_emailON users(email);
ALTERTABLE users ADD COLUMN phone VARCHAR(20);