Forum Moderators: coopster
Basically I have a table with say 10 fields in it. One of these fields contains a Credit Card Number and the field name is "ccn"
Instead of typing out (in PHP):
Select field1,field2,field3,field4,RIGHT(ccn,4),field6,field7 ...etc
I want to do:
Select *,RIGHT(ccn,4) from table
But the only problem is, the original ccn field (with all the numbers is still returned in the query. Is there a way to be more selective with the * query?
Basically I would like the RIGHT(ccn,4) statement to replace the full ccn field in the final output.
Thanks.
In a query such as
SELECT what_to_select, what_to_select indicates what you want to see. This can be a list of columns, or * to indicate all columns. With MySQL, it's one or the other [mysql.com].
Select *,RIGHT(ccn,4) as maskedccn from table and in your script, call maskedccn instead of ccn. Of course we all know not to store credit card data (unencrypted or otherwise) on a public server. Don't know whether the OP is doing this or not, but just wanted to mention it for the benefit of those who may not know. Credit card security should be taken seriously.
Just for clarification, the result set in this case is still going to contain the full ccn field along with all the other columns in the table, but now having an additional maskedccn field appended:
field1,field2,field3,field4,ccn,field6,field7...maskedccn
Don't know whether the OP is doing this or not
Thought maybe there was some undocumented (or very well hidden) mySQL function that could remove a column from the final output.
So its either SELECT *,RIGHT(ccn,4) as cc4
-or-
SELECT
one,two,three,RIGHT(ccn,4),five,six....etc
Thanks for the fast response on this.