多表查询
select albums.name,albums.year,artists.name from albums,artists;
SELECT * FROM albums JOIN artists ON albums.artist_id = artists.id;
SELECT * FROM albums LEFT JOIN artists ON albums.artist_id=artists.id;
select albums.name as 'Album',albums.year,artists.name as 'Artist' from albums join artists on albums.artist_id = artists.id where album...
计数
SELECT COUNT(*) FROM table_name; 总数
select count(*) from table_name where price=0; 价格等于0的数量
select price, count(*) from table_name group by price; //Count the number of apps at each price.
select price,count(*) from table_name where column > 20000 group by price;
SELECT SUM(column) FROM table_name;
SELECT category, SUM(column) FROM fake_...
查询
SELECT * FROM table;
SELECT column1,column2 FROM table;
SELECT DISTINCT column FROM table;
SELECT * FROM table WHERE id > 8; 其他符号(=、!=、>、<、>=、<=)
模糊查询
SELECT * FROM table where name LIKE 'Se_en'; 通配符(%)
SELECT * FROM table WHERE name LIKE '%man%';
select * from movies where name between 'A' and 'J';
select * from mov...