MySQL dynamic search query procedure -


the mysql query should return

1) true along comma(,) separated list of station_name table station station_name like input specified buy user.

for ex:

input = a, output= (agra,ajmer,amritsar,ambala).

input = am, output= (amritsar, ambala) 

2) false, when no such station exists

3) error.

detailed procedure appreciated, new mysql. in advance.. :)

you don't need procedure, select returns 1 row on success or no rows on failure:

select group_concat(station_name) station station_name ? 

where ? placeholder user entered search.

group_concat mysql-specific feature.

if must use procedure, this:

create procedure stationsearch (in likewhat varchar(255), out rslt text) begin     select group_concat(distinct station_name order station_name) rslt station station_name likewhat; end 

used this:

call stationsearch('am%',@rslt); select @rslt; 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -