1

I tried looking everywhere but the only results id get is how to get the first 3 letters of a column's content, but that's not what I want. To make my point more clear I'll give an example: if there's a column called Employee_name and it had josh and Emily in it, I want to be able to get the first 3 letters of its name, which in this case would be Emp

1 Answers1

2

Maybe somethin like this?

SELECT SUBSTRING(`COLUMN_NAME`, 1, 3) AS col
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='your_db_name' 
    AND `TABLE_NAME`='your_table_name';
Ivan
  • 76
  • 7