Reputation: 4579
I have a form wich permits the users to leave inputs unfilled. I register those fields as decimal(2) "0.00" in the database.
After the form is inserted in the database, I want to permit the users to edit that form.
My question is, for performance's sake, how do I select only the columns different than 0.00 for that specific row corresponding to the user's form input?
By the way, I am using CodeIgniter's Active Record functionality but I don't get upset if I get what I need using a string sql query :D
A pseudocode I imagine:
select _columns-greater-than-zero_ from _table-name_ where id=_row-id_
Upvotes: 0
Views: 688
Reputation: 2743
So you want to select a variable list of columns based on what value a specific row has in that column? Why would you want to do that? It would not improve performance at all, and in fact, the extra checks it would need to run against the values of those columns would make the query slower.
If you're trying to figure out whether or not to display the column on a page, just add some conditions to your code to check if the value in the returned row equals 0.
Upvotes: 3