0

I want to get all the data from a table in SQL.The following command can be used:

select * from table_name

But it seems that using * decreases effeciency, so is there any other way ?

Vaibhav Jain
  • 3,729
  • 3
  • 25
  • 42
Nitish Bangad
  • 151
  • 1
  • 9
  • 1
    Use direct fields recounting in query, like `SELECT foo, bar, baz, ... FROM t` - but it will not be much faster – Alma Do Oct 21 '13 at 11:12

2 Answers2

0

You can use following syntax:

SELECT fieldname1,fieldname2,fieldname3 FROM table_name;

You can also optimize it by using limit. Just fetch the number of record you wanted at once.

SELECT fieldname1,fieldname2,fieldname3 FROM table_name LIMIT 10;
Vaibhav Jain
  • 3,729
  • 3
  • 25
  • 42
Dinesh Saini
  • 2,917
  • 2
  • 30
  • 48
0

You can use

 SELECT col_name1, col_name2, col_name3 from Table_Name 

This approach is Good compare with SELECT * from Table_Name

The reason to use this approach is at some point, an extra column may be added to that table, and would cause unneeded data to be brought back from the query.

Why Not preferring SELECT * from Table_Name : Reference : Why not preferring SELECT *

Vaibhav Jain
  • 3,729
  • 3
  • 25
  • 42