Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

retrieve info

by bigup401 (Pilgrim)
on Sep 11, 2018 at 21:59 UTC ( [id://1222161]=perlquestion: print w/replies, xml ) Need Help??

bigup401 has asked for the wisdom of the Perl Monks concerning the following question:

i want to search info from db by age,name and country. but i get blank output

if ($input) { my $search = $DBH->prepare("SELECT * FROM tble WHERE CONCAT(NAME, ', ' +, AGE, ', ', COUNTRY) LIKE ?"); $search->execute($input); my $row; while (my $row = $search->fetchrow()) { print "$row\n"; } }

Replies are listed 'Best First'.
Re: retrieve info
by huck (Prior) on Sep 11, 2018 at 23:32 UTC

    what does $input look like? does it contain a %?

    possibly you might want something like $search->execute('%'.$input.'%'); SQL LIKE Operator

      thanks

        As part of basic testing/debugging you should always run your the SQL you have in your code against your database using your test data using one of the standard interfaces. For anything complex I develop my SQL code in SQL Developer (oracle specific) to ensure it all works as expected, before embedding it in my perl code.

Re: retrieve info
by Anonymous Monk on Sep 11, 2018 at 23:17 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1222161]
Approved by beech
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found