Re: INNER JOIN Using ADOQuery
- From: "Ray Marron" <me@xxxxxxxxxxx>
- Date: Fri, 31 Mar 2006 13:27:47 -0700
"eddela" <llcrcaero@xxxxxxxxx> wrote in message
news:442d7b0a@xxxxxxxxxxxxxxxxxxxxxxxxx
[SNIP & dreadful geoForum quoting manually cleaned up]
Another question about this. Suppose I want to add another where
statement,such as
WHERE t1.Item = t2.Item AND t1.Item = x
ORDER BY t2.Vendor
{where x is a certain product name entered by the user into an
editbox.}
If I use the following format, the code executes correctly, without
the WHERE and ORDER BY statemente, When the WHERE and/or ORDER BY
statements are added, I get the same error messages as before. Please
tell me what's missing or wrong? Thank you again. Ed
I can't tell you exactly what's wrong unless you post the exact code that's
generating the error message.
My intuition tells me you're probably not putting quotes around x, which
would lead the parser to think it's a field name and not be able to
determine the table it came from.
I suggest you read about query field parameters (TParam[s]). They take care
of things like quoting and date formatting automatically. Then you could do
something like this:
Query.SQL.Text := 'SELECT t1.item, t2.vendor FROM table1 t1, table2 t2 WHERE
t1.item = t2.item AND t1.foo = :Foo';
Query.ParamByName('Foo').AsString := FooEdit.Text;
Query.Open;
--
Ray Marron
.
- References:
- Re: INNER JOIN Using ADOQuery
- From: Ray Marron
- Re: INNER JOIN Using ADOQuery
- Prev by Date: Re: Dynamically Adding an Index to a query
- Previous by thread: Re: INNER JOIN Using ADOQuery
- Next by thread: How to verify if Access database exists...
- Index(es):