Author Archives: Admin

Selecting single column or some columns using mysql query?

See the Example

Select * from mydoubts_data

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
| GORT | Shaji | S |
| GKL | James | P |
| IND | Abdul | ZO |
| VIS | Sunil | F |
+———+————————-+——————–+

For only Name column we will use the following query.

Select Name from mydoubts_data where name=’vasanthan’

+———–
| NAME |
+———-+
| Vasanthan|
+———-+

Selecting a particular record using mysql query?

See the Example

Select * from mydoubts_data

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
| GORT | Shaji | S |
| GKL | James | P |
| IND | Abdul | ZO |
| VIS | Sunil | F |
+———+————————-+——————–+

For finding the particular record we will use the following query.

Select * from mydoubts_data where name=’vasanthan’

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
+———+————————-+——————–+

Importance of wild card ‘*’ in mysql

See the Example

Select * from mydoubts_data

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
| GORT | Shaji | S |
| GKL | James | P |
| IND | Abdul | ZO |
| VIS | Sunil | F |
+———+————————-+——————–+

For finding all the records from a table we will use the following query.

Select * from mydoubts_data

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
| GORT | Shaji | S |
| GKL | James | P |
| IND | Abdul | ZO |
| VIS | Sunil | F |
+———+————————-+——————–+

Finding how many rows in a table in Mysql?

See the Example

Select * from mydoubts_data

+———+————————-+——————–+
| EMPCODE | NAME | SALARAY CODE |
+———+————————-+——————–+
| 787 | Vasanthan | K |
| GORT | Shaji | S |
| GKL | James | P |
| IND | Abdul | ZO |
| VIS | Sunil | F |
+———+————————-+——————–+

For finding the number of rows in a table use the following quries.

Select count(*) from mydoubts_data

+———-+
| count(*) |
+———-+
| 5 |
+———-+

Indexing in mysql using php

indexes in mysql will increase the speed of your mysql queries.
indexes are doing cloumn basis.

for example if you have table with following fields

ID,jobdescription,salary

In this case to speed up the queries with jobdescription. then create an index for jobdescription.
CREATE TABLE mydoubts_data (
jobdescription varchar, INDEX (jobdescription),
salary INT(50),
)