0

I basically want to select all columns of my MySQL table, but want to change the datatype of only one column namely Patient_Number using CAST function only. Here is a screenshot of my MySQL table

enter image description here

So as my output, I want a similar table as I have shown in the screenshot, just want to have the datatype of Patient_Number from INT to VARCHAR.

I tried executing the following queries:

select * cast(Patient_Number as varchar) from clinic_data;
select * from clinic_data cast(Patient_Number as varchar);

But only got the following error message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'cast(Patient_Number as char)' at line 1

James Z
  • 12,209
  • 10
  • 24
  • 44
Sam Varghese
  • 428
  • 1
  • 5
  • 14

1 Answers1

0

SELECT * is basically not a good idea

But you need a comma, between both statements

And it should be char for the cast

select *, cast(Patient_Number as char) from clinic_data;

db<>fiddle here

Dušan Stokić
  • 161
  • 1
  • 2
  • 13
nbk
  • 45,398
  • 8
  • 30
  • 47