please help me in this,how would i do some recursive statement in my stored procedure.
here is what i want

-- @requestcode will genereate some random string
set @requestcode = (SELECT substring(@username,0,3)+'-'+SUBSTRING(CONVERT(varchar(255), NEWID()), 0, 9))

-- then i want to check if the string generated is existing to 'sampletable'
select @requestcode from sampletable

-- if it is existing back to the @requestcode query until it is not existing

thanks in advance

Member Avatar for LastMitch

please help me in this,how would i do some recursive statement in my stored procedure.

I think a table would be much easier to understand rather with those 2 querys.

Take a look at this:

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Which example(s) is the closet to your issue or your example?

Recursive CTEs can be used.

Use Cte for that .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.