Jump to content

Anything that does something like SELECT * EXCEPT?


Fog Juice

Recommended Posts

Hey everyone,

 

Is there a mysql command that will select every column from a table with the exemption of the column you list, without having to type in each column name?

 

Something like this psudo line here "select * except id FROM user_display". If this command were real, it would select all columns but id. Is there a command that can do this?

 

 

Thanks,

Chris

        $sql = "SELECT filter, app_details, logo FROM user_display WHERE user_id = $id";
$results = mysql_query($sql) or die(mysql_error().' '.mysql_errno());
while($row = mysql_fetch_array($results))
{

	for($i = 0; $i < mysql_num_fields($results); $i++)
	{
		$return .=  mysql_field_name($results, $i).$row[mysql_field_name($results, $i)].",";
	}
}

 

see how I have to type in every field name in $sql that I want? I will eventually be adding more columns to that table and instead of having to go into the script to update the select statement, i'd rather just make an exemption to exclude the id and user_id columns since the functionality i'm using this part for doesn't require them.

Dont get into the habit of using *

 

Its terrible for performance, I used to do it because I was lazy, and didnt half notice the difference when only taking what I needed

 

I dont think there is such a feature direct from mysql

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.