i want result -> Student_id,Name,Address,Marks
Thank you.
If you have several other columns and want to display some of them, then use :
SELECT Student_id, Name, Address, Marks
FROM Student
Otherwise, if you only have these 4 columns in your table, then :
SELECT *
FROM Student
If you only want the names of your columns without data, then :
SELECT * FROM Student WHERE 1=0
/*or*/
SELECT Student_id, Name, Address, Marks FROM Student WHERE 1=0
Something like this should get you the column names, if that's what you're looking for.
select *
from table
where 1=2
MYSQL, MS SQL and Postgresql (thanks @christophe)
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_SCHEMA = 'database_name'
AND TABLE_NAME = 'table_name'
PIVOT the results if you need column names in one line
<%
Dim rs1, i
Set rs1 = Server.CreateObject( "ADODB.Recordset" )
set rs1 = yourconnection.execute( "SELECT * FROM Student" )
For i=0 to rs1.Fields.Count-1
Response.Write rs1.fields(i).name & ", "
Next
%>
you will get: Student_id, Name, Address, Marks