access数据库sql语句select
时间: 2023-12-15 21:06:48 浏览: 152
以下是几个常用的Access数据库SQL语句select的例子:
1. 查询表中所有数据
```sql
SELECT * FROM table_name;
```
2. 查询表中指定列的数据
```sql
SELECT column1, column2, ... FROM table_name;
```
3. 查询表中符合条件的数据
```sql
SELECT * FROM table_name WHERE condition;
```
4. 查询表中前n条数据
```sql
SELECT TOP n * FROM table_name;
```
5. 查询表中前n条数据并按指定列排序
```sql
SELECT TOP n * FROM table_name ORDER BY column_name;
```
6. 查询表中前n条数据并按指定列随机排序
```sql
SELECT TOP n * FROM table_name ORDER BY Rnd(id);
```
7. 查询表中前n条数据并按指定列随机排序(SQL Server)
```sql
SELECT TOP n * FROM table_name ORDER BY NEWID();
```
8. 查询两个表的笛卡尔积
```sql
SELECT * FROM table1, table2;
```
9. 查询两个表的笛卡尔积(Access)
```sql
SELECT * FROM table1, table2 WHERE 1=1;
```
阅读全文