On Tue, May 08, 2001 at 01:35:17PM -0400, Richard Lytle wrote:
> Hi,
>
> I am able to prepare a select query to an Ingress database requesting
> multiple column values from 1 table where a column value matches a
> variable value, ie,"my $sth->prepare("SELECT p.fname, p.lname, p.dob,
> p.sex, p.idnum FROM emppid p WHERE p.idnum=$idnum"). This query works.
>
> When I try to query multiple tables, eg...("SELECT p.fname, p.lname,
> p.dob, e.ssn, e.race FROM emppid p, empinfo e WHERE p.idnum=$idnum AND
> e.unitnum=p.unitnum") I get "SYNTAX error on 'AND' ", and various other
> errors because I have tried to configure the WHERE part of the query
> numerous times - and I should mention that I have used sql very little -
What does $idnum contain, _exactly_, when you get these errors?
Try this:
my $sql = <<"EndOfSQL";
SELECT p.fname, p.lname, p.dob, p.sex, p.idnum
FROM emppid p, empinfo e
WHERE p.idnum=$idnum AND e.unitnum=p.unitnum
EndOfSQL
print $sql;
Ronald