Fog Juice Posted February 14, 2008 Share Posted February 14, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/91119-anything-that-does-something-like-select-except/ Share on other sites More sharing options...
effigy Posted February 14, 2008 Share Posted February 14, 2008 I've never seen this feature. Are you just trying to save screen space in the CLI? Quote Link to comment https://forums.phpfreaks.com/topic/91119-anything-that-does-something-like-select-except/#findComment-467015 Share on other sites More sharing options...
Fog Juice Posted February 14, 2008 Author Share Posted February 14, 2008 $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. Quote Link to comment https://forums.phpfreaks.com/topic/91119-anything-that-does-something-like-select-except/#findComment-467036 Share on other sites More sharing options...
effigy Posted February 15, 2008 Share Posted February 15, 2008 You'll have to do this in PHP: while (rows) { while (cols) { skip col if id or user_id else, process } } Quote Link to comment https://forums.phpfreaks.com/topic/91119-anything-that-does-something-like-select-except/#findComment-467707 Share on other sites More sharing options...
jaymc Posted February 15, 2008 Share Posted February 15, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/91119-anything-that-does-something-like-select-except/#findComment-467717 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.