title: Need to run a SUBSTRING_INDEX inside of a SUBSTRING
body: <p>I have a LOAD DATA mysql query im trying to run and need help to fix one thing.</p>
  
  <p>Here is the query im running</p>
  
  <pre><code>$query = "LOAD DATA LOCAL INFILE '$file_app' 
      INTO TABLE tbl_user_tmp 
      LINES STARTING BY '{' 
      TERMINATED BY '/&gt;' 
      (@name) 
      set 
      name=SUBSTRING_INDEX(@name,'\"',-2),
      activity=SUBSTRING_INDEX(SUBSTRING_INDEX(@name,'}',1),'/',1),
      class=SUBSTRING_INDEX(SUBSTRING_INDEX(@name,'}',1),'/',-1),
      user = '$user'" ;
  </code></pre>
  
  <p>Here is the example of data from file im trying to load.</p>
  
  <pre><code>&lt;item component="ComponentInfo{com.apps.aaa.roadside/com.apps.aaa.roadside.Splash}" drawable="aaa_roadside1" /&gt;
  </code></pre>
  
  <p>With the above query i get the following</p>
  
  <pre><code>name=aaa_roadside1" 
  activity=com.apps.aaa.roadside
  class=com.apps.aaa.roadside.Splash
  </code></pre>
  
  <p>Everything is correct but name. I need to removed that last "</p>
  
  <p>I thought the below query would work but it does not. any ideas?</p>
  
  <p>This was working before when i had TERMINATED BY set to this '\" />'
  However this will not account for entires that might not have that space at end like this</p>
  
  <pre><code>&lt;item component="ComponentInfo{com.apps.aaa.roadside/com.apps.aaa.roadside.Splash}" drawable="aaa_roadside1"/&gt;
  </code></pre>
  
  <p>I need to account for both</p>
  
  <pre><code>$query = "LOAD DATA LOCAL INFILE '$file_app' 
  INTO TABLE tbl_user_tmp 
  LINES STARTING BY '{' 
  TERMINATED BY '/&gt;' 
  (@name) 
  set 
  name=SUBSTRING(SUBSTRING_INDEX(@name,'\"',-2),-1),
  activity=SUBSTRING_INDEX(SUBSTRING_INDEX(@name,'}',1),'/',1),
  class=SUBSTRING_INDEX(SUBSTRING_INDEX(@name,'}',1),'/',-1),
  user = '$user'" ;
  </code></pre>