Hopefully there's an easy answer - WHERE statement Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've created a database with numerous queries and reports, but now I need to
automate the reports. What I want to do is start with a table like the
following

VARIABLE VALUE
DATE1 10/15/2004
DATE2 12/15/2004
PUB1 Ubisoft
etc....

I want to be change theses variables for each new report and then have those
qualifiers carry over to all queries and reports so I don't have to do it
manually.

I thought about doing this with SQL WHERE statements. But I don't know if it
will allow me to use variables from a table. The sample SQL query statement
looks like:

SELECT PageValue.Name, PageValue.Rank
FROM PageValue
WHERE NAME=[PUB1 FROM MY VariableTable WOULD GO HERE]
ORDER BY Rank;

Is there any way to do this in SQL?
Or, better yet, is there anything in access 2003 that would let me do this
easier?
I hope I haven't muddled the question too badly.
 
One way is to join the tables. If you're using the GUI query builder, you'd
add your new table and drag the PUB1 field on top of the NAME field in the
PageValue table. (BTW, Name isn't a good choice to a field name: it's a
reserved word, and using it can lead to problems)

The SQL would look like:

SELECT PageValue.Name, PageValue.Rank
FROM PageValue
INNER JOIN VariableTable
ON PageValue.Name = VariableTable.PUB1
ORDER BY Rank;
 
Thank you for the help...

I'm new at db programming, and I've got more data than I know what to do
with at this point.

Thankfully, with your help, I realize I've been asking the wrong question.
I certainly don't need dates, publishers and other items in the same column.
There are much easier solutions. Your GUI solution worked perfectly. I just
need to get everything settled a little better.

About the Reserved Word problem, thanks also. I'll check that out online and
get it fixed!
 
Back
Top