Thursday, January 8, 2009

Select Tutorial

There are many ways to select data from tables I will go through them.

Counting rows

Counting Rows :

COUNT(*) counts the number of rows in a table.

The syntax is
select count(*) from table name
here is an Example

select count(*) from test;
| count(*) |
| 148|
1 row in set (0.00 sec)

This query shows the number of rows in the test table

The most basic of querys in the

select everything query
and now you learned how to insert data into the table, we should probably check the datas is stored correctly. To do so, we use the SELECT statement.

The Select syntax is

SELECT what_to_select from table name;

To view all the data from the table, we use the below query.

select * from test;
OfficeCode AccountCode AccountName SecType
1111 084534334 Test 1
1112 3434343435 3434 2
2 rows in set (0.00 sec)
The above example query will list the complete details of the test table. Here * will select all the columns from the

To also limit your select

select top 10 * from test

this will show the top 10 rows

OfficeCode AccountCode AccountName
6 6670708 test
6 6610108 test2
6 6044208 test3
6 6045208 test4
6 6049208 test5
6 6046208 test6
6 6050208 test7
6 6047208 test8
6 6048208 test9
6 6041208 test10

Bookmark and Share

No comments:

Post a Comment