From: Derick H Siddoway Date: March 25 1999 3:53pm Subject: Re: Extracting a given row using Perl API List-Archive: http://lists.mysql.com/mysql/960 Message-Id: <0F30836FA5BE301E*/c=us/admd=attmail/prmd=amex/o=unresolved/ou=HUB1/ou=AMEX/s=Siddoway/g=Derick/i=H/@MHS> What you probably want to do is something like this: my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE phone_book.last='$FOO'"); OR store the value in $FOO like this $FOO = "'Blow'"; You're not storing the single quotes into $FOO unless you're very specific about it -- because perl is so forgiving about which quotes you use. When you say $FOO = 'Blow'; perl assumes that you're storing the string "Blow" into the scalar variable. My preference is to put the single quotes into the squeel statement instead of in the string because mnemonically it makes more sense to me -- it's a squeel thing, so it should go in the squeel statement. I guess I should note that I pronounce SQL as "squeel" instead of the insidious "sequel" on purpose. -- derick From: wrmattil%ix.netcom.com@Internet on 03/25/99 02:01 AM To: mysql%lists.mysql.com@Internet cc: (bcc: Derick H Siddoway/TC/TRS/American Express) Subject: Extracting a given row using Perl API Can anyone tell me where the problem here is ??? Given a rather simple table phone +----------+----------+------------+ |first |last |phone | +----------+----------+------------+ |Joe |Blow |800-555-1212| +----------+----------+------------+ In this rather simplistic example: my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE phone_book.last='Blow'"); works while the following does not; my $sth = $dbh->prepare("SELECT first,last,phone FROM $table WHERE phone_book.last=$FOO"); Where $FOO = 'Blow'; And the error message returned is as follows: DBD::mysql::st execute failed: Unknown column 'Blow' in 'where clause' at ./find-record line 23. I'm sure that I am making a grievous error here but just can't see it. Can anyone shed some light on this ??? Thanks in Advance Bill -- William R. Mattil | Fred Astaire wasn't so great. wrmattil@stripped | Ginger had to do it all backwards (972) 399-4106 | and... in high heels. --------------------------------------------------------------------- Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before posting. To request this thread, e-mail mysql-thread934@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.