Jump to content

Archived

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

sanosuke001

Select all but - is it possible

Recommended Posts

I have a table with probably 200 columns. I want to view all but a handful of them. Is there a way without typing them all out in a select col1, col2 ... col200 from table; kinda way?

Or better yet, how can I compare two different databases. What I am trying to do is see the differences between two databases and so far, the only thing I can think of is to print them all out to a text file and then run a diff on them. An answer for either would be awesome. Thanks for the help!


Stephen

Share this post


Link to post
Share on other sites
Not really... but you could DESCRIBE the table in PHP, get back a hash of column names, and then remove the ones you don't want, and have the script compose the desired column list.  Same goes for comparisons.

Share this post


Link to post
Share on other sites
another idea, and i'm sure fenway will have a better idea whether or not this is optimal, but if you're doing a ton of queries like that, why not split your table into two so that the most used columns are in one table? i know it's not really normalized, but the other option i can think of is to create a view with only those columns that you're wanting to select, then you only have to select * from the view.

fenway, would that be a reasonable solution when you're working with so many columns?

Share this post


Link to post
Share on other sites
I'm not using it all that often. Even with a view, I'd have to type it all out. What I am doing is we have a device that stores patient data in a database and once in a while an error creeps into the DB. WE have to fix it and thats easy. The hard part is determining if any of the data was changed. I know its very unlikely that an update would change something other than what we told it to, but its patient data and we want to be certain. Also, we're using SQLite so I don't even know if there are views in it...


Thanks for the help though.

Share this post


Link to post
Share on other sites
[quote author=obsidian link=topic=108841.msg438454#msg438454 date=1158803213]
another idea, and i'm sure fenway will have a better idea whether or not this is optimal, but if you're doing a ton of queries like that, why not split your table into two so that the most used columns are in one table? i know it's not really normalized, but the other option i can think of is to create a view with only those columns that you're wanting to select, then you only have to select * from the view.

fenway, would that be a reasonable solution when you're working with so many columns?
[/quote]
There's nothing wrong with splitting the table horizontally, and in fact with InnoDB, it often makes a lot of sense... but views have their own issues (esp. with indexing), so they have many limitations.  Plus, it doesn't sound like it's going to be in constant use.

I would still recommend the dynamic column listing.

Share this post


Link to post
Share on other sites

×

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.