SQL all but one field

zester

New Member
Messages
23
Reaction score
0
Points
0
Hi all
what is SQL code to select all the fields but one?
i.e.
select "all but description" from table
where ID = 1
So it should return the values of all the fields exsept the description field.
Zest out
 

LHVWB

New Member
Messages
1,308
Reaction score
0
Points
0
I don't believe that there is an easy way of doing this.

MySQL Select Reference:
http://dev.mysql.com/doc/refman/5.0/en/select.html

Is there any reason why you can't just use "SELECT ALL" and then ignore the data you don't want or make a list of all the data that you do want?

Making a list of all of the columns is probably the best idea, because it means that you will have a list of columns for easy reference in your db queries.
 

jspcodes

New Member
Messages
60
Reaction score
0
Points
0
what gaming moderator said correct. You may use select * from and neglect the field alone. The query would be much simpler.
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
In PHP, you'd use something like:

$row = mysql_fetch_array(mysql_query("SELECT * FROM tblname WHERE fieldname='contents'"));

And then address it in your script using echo like this:

echo $row['fieldname'];

There's no point neglecting things from your query, it won't save much time and will waste the time it takes to type it really. You might need to use the other information later anyway.

-Luke.
 
Top