can I select columns based on their name in Mysql? is there a way to select columns using '%' or 'like'?
for example:
I have a table with 20 columns , and 4 of them are starting with &quot;GPS_&quot;(GPS_long,GPS_Lat,GPS_sat,GPS_Speed)
I want to run something like this:( I know this is NOT the way...)
SELECT like '%GPS_%' FROM sample.table

so it will bring only the GPS columns  ?
Thanks ,
No, you can't, nor should you even consider it.
This is a variation on ...

Never use &quot;select *&quot; in Production Code

.. and the risk is the same.
At the moment, your table is nice and tidy, with a few columns of limited size.
At some point, someone is going have the &quot;Great Idea&quot; of adding a whole bunch of BLOB fields and populating them with terabytes of video data.  If you're unlucky and those new fields just happen to be prefixed &quot;GPS_&quot;, then your code would start retrieving these fields, even though it has absolutely no interest in them.
Always specify the fields that you want to retrieve explicitly.