mysql - Use PDO's bind param multiple times as variable -


i searching on internet , didnt find solution.

lets want use 1 paramerer in pdo multiple times.

select * `users` inner join `user_names` on `users`.`id`=`user_names`.`id` `user_names`.`name` concat('%', ? ,'%') or `users`.`name` concat('%', ? ,'%') 

how can avoid use ? 2 times ? looking this:

select ? `search_name`, * `users` inner join `user_names` on `users`.`id`=`user_names`.`id` `user_names`.`name` concat('%', `search_name` ,'%') or `users`.`name` concat('%', `search_name` ,'%') 

thank you

you can join subselect contains parameter value or (like below) complete search string.

select * `users` inner join `user_names` on `users`.`id`=`user_names`.`id` cross join (select concat('%', x.name, '%') searchstring) x `user_names`.`name` x.searchstring or `users`.`name` x.searchstring 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -