0

New to all this but I have a table called Table1 with a column name cat1 contents is : delimited:

info:something:else

I want to select the information to the right of the second :

I am using the following statement:

SELECT SUBSTRING_INDEX(cat1, ':', -1) FROM Table1

It gives me an error

ending quote expected ' near (near)

but if I change the : to something like ; it will run with no error.

Any help would be much appreciated.

chris85
  • 23,846
  • 7
  • 34
  • 51
Maze.Ezam
  • 19
  • 3
  • 2
    Don't store delimited data, just use multiple rows. https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad There also is no `near` in your query, where does that come from? – chris85 Jul 24 '17 at 04:06
  • 1
    [First normal form - Wikipedia](https://en.wikipedia.org/wiki/First_normal_form) –  Jul 24 '17 at 04:10
  • Works for me. Can you share the PHP code you use to call this query? – Mureinik Jul 24 '17 at 04:15
  • Hi I am using phpmyadmin to write the code not using PHP directly. The error was in the form of a red cross to the left of my script and said exactly that. I ran the script and it would just hang there for a very long time. I have just ran it again and it has worked though it took like 15 mins but the mysql says it only took 0.051 seconds. This is really strange. – Maze.Ezam Jul 24 '17 at 04:48
  • The PHPmyadmin interface lies about execution time frequently, use the real mysql interface to get the real execution time. – chris85 Jul 24 '17 at 13:38

0 Answers0