At 11:09 PM -0400 4/28/1999, Charles Kirby wrote:
>Thanks, I'm still trying (and failing)...
>maybe it has something to do with the fact that "sid" is an integer, and
>that I can't get wildcards to work.
>For instance, this works from the command line:
>
>mysql> select sid from slips;
> this gets all the "sid"s, but if I try to do:
>
>mysql> select sid from slips where sid=?;
> or "" where sid='?';, sid=%; etc etc, I always
>get "Empty set (0.00 sec)"
>
>Is there a way of specifying the wildcard for integer fields?
I don't really understand what you're trying to accomplish, exactly,
with the above. But, yes, in MySQL, you can use wildcards on numeric
fields. However, values containing wildcards should be specified
as a string, and you must use the LIKE (not =) operator. So, for
instance, to find all sid values containing a "5", you could
say: where sid like "%5%"
Is that really what you want, though? It doesn't seem to have much
to do with DBI placeholders (i.e., you can't use DBI placeholders
in the mysql client).
>
>Thanks, ck
>On Wed, 28 Apr 1999, Vivek Khera wrote:
>
>> >>>>> "CK" == Charles Kirby <kirbych@stripped>
> writes:
>>
>> CK> my $dbh = DBI->connect("DBI:mysql:$dbname", $dbuser, $dbpasswd)
>> CK> or die "can't connect: $DBI::errstr\n";
>>
>> CK> my $query = <<"EOS";
>> CK> SELECT sid
>> CK> FROM slips
>> CK> WHERE sid='1'
>> CK> EOS
>> CK> my $sth = $dbh->prepare($query) or die "can't prepare $query: ",
>> CK> $dbh->errstr, "
>> CK> \n";
>> CK> $sth->execute($sid);
>>
>> If you want to pass a parameter to execute and have it that value
>> filled into your SQL, then you need to use "placeholders" in your
>> $query string. A place holder is nothing more than a ? symbol. I'm
>> assuming to get the desired effect, you want to change
>>
>> sid='1'
>>
>> to
>>
>> sid=?
>>
>> and then re-try your program.
>>
>> CK> while(@row = $sth->fetchrow_array) {
>> CK> print "@row\n";
>> CK> }
>>
>>
>> v.
>>
>> --
>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>> Vivek Khera, Ph.D. Khera Communications, Inc.
>> Internet: khera@stripped Rockville, MD +1-301-545-6996
>> PGP & MIME spoken here http://www.kciLink.com/home/khera/
>>
>
>
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread2572@stripped
>
>To unsubscribe, send a message to the address shown in the
>List-Unsubscribe header of this message. If you cannot see it,
>e-mail mysql-unsubscribe@stripped instead.
--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/