what about duplicating the column as a varchar and querying the new column while leaving the old column unchanged?
Is there a way to duplicate an entire column and have all new entries duplicated as well? Problem is I have three different dashboards that share that same data. New data gets added every day.
Yes, like this (in Navicat):
I have an existing price column. Iâve created a virtual column (which will take no extra space - itâs calculated on the fly) with âpriceâ as the expression and defined as VARCHAR - named âprice_textâ. Having created this column, you will have a new, text version of the price column. It would be a duplicate and will keep in sync with the main price column.
Virtual columns can also be stored - so they do take space. Iâm not sure which you will need in this case.
Strange, I have the latest version of Navicat but donât have the virtual option? Does it need to be turned on somewhere?
I donât think so - but the problem could be that youâre using an older version of MySQL. You need version 5.7. I should have mentioned that.
Yeah, that could be it. Mine is 5.6.14 ...... not having a good day. lol
Thatâs a pity. You could create a new column for you VARCHAR version and update it to have the same values as the INT number column. Then create a trigger to set the value of this new column to the INT column - on both insert and update. I think this should produce the same result.
The query builder wonât allow it, it is very strict. You can edit the json in the action file to change it to begins with. Just select equal first, then edit the file and change the equal operator in begins_with. Or choose a string column and use the begins with condition there and change the column name afterwards in the action file.
Iâm going to lose this battle but anyways
Why not just allow it in the query builder if it works?
I suspect because it doesn work in all platforms or indeed all versions of mysql
Patrickâs solution, assuming it works, doesnât seem a bad workaround
I know with MSSQL you have to CAST the value first to the correct type or you will get an error. MYSQL seems to be less strict and does it for you. Other databases I donât know, but according to the standard it should give an error.