Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
SET stringIndex = INSTR(filterText, 'State1') - 8; // what this line is doing??


/* what is following block of code is doing */
set @sql=
CONCAT('
Create TEMPORARY TABLE tblGeo
(SELECT Distinct State, District, Code FROM tblStateDistrict WHERE Country = ''India'');
');

PREPARE stmt FROM @sql;
EXECUTE stmt;


What I have tried:

i copied code and paste it on google, but i couldn't find any explanation on net
Posted
Updated 22-Sep-19 20:53pm

1 solution

See here: MySQL INSTR() Function[^] and here MySQL CONCAT() Function[^]

You should be able to work it out from there.
 
Share this answer
 
Comments
Akshay malvankar 23-Sep-19 3:26am    
what that - 8 is doing
Herman<T>.Instance 23-Sep-19 3:28am    
It is setting begin of string to 'distinct '
OriginalGriff 23-Sep-19 3:34am    
Moving back 8 characters from the start of the match.
Read the links: INSTR returns the character index of the first character in "State1" it finds in filterText. "- 8" move back from that to the index of a character eight before the 'S'.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900