Is it possible to fetch or update table data by field type? If possible please tell me with a sample code.
|
|
Yes, it's very possible to accomplish that but not with a unique query! First, you need to know where to look for metadata: This kind of information is stored into an internal mysql database called
The solution I know for your problem involves two queries. First one will return a list of columns with a given data_type (you can specify the database, and table you want to look for too):
With the list of column names that satisfy the properties you want (a given data type, in your specific case) all you need to do is a secondary query to select or update data from that list of fields. I searched in MySql documentation and unfortunately there is no way to select or update a dynamic list of fields only with SQL, thats why a secondary generated query is needed. Hope this helps. |
|||||
|