Jump to content

Anything that does something like SELECT * EXCEPT?


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.