Dr ZIZO
Dr ZIZO

Reputation: 333

select limited data from column

I need to select limited number of characters from one column. I've tried :

SELECT substring_index(COLUMN_NAME, 250);

BUT the column name will be identified as normal text string.

EXAMPLE : I have column "Description" and I want to retrieve first 250 characters of the description to put into php variable.

It works when using substring NOT substring_index.

Upvotes: 0

Views: 127

Answers (2)

Jon Marnock
Jon Marnock

Reputation: 3225

Do you just need to add "AS Description" after the substring function call so the column gets renamed back to just Description in your PHP result array?

Upvotes: 1

Alain Collins
Alain Collins

Reputation: 16362

With more clarification from the poster, putting the answer here, in case he/she chooses to accept it.

substring(description,1,250)

Upvotes: 1

Related Questions