What is wrong with my query???

  • Thread starter Thread starter Van T. Dinh
  • Start date Start date
V

Van T. Dinh

On the third last line of the second Query SQL, you have:

book,deptno

That should be

book.deptno

See also my reply to your later thread re wild-cards.
 
I made two queries.. Query A works, but Query B dosn't.
A, is supposed to pull somebodies information when doing a search by
department name. It can also pull stuff up by an alternate department name.
the keys obviously are deptno.


Query A: WORKING ------
SELECT book.recid,book.l_name,book.f_name,
book.mid_init,book.phone,deptnames.deptname
FROM book,deptnames
WHERE book.deptno = deptnames.deptno
AND (deptnames.deptname LIKE "%user_input%"
OR deptnames.altname LIKE "%user_input%")
ORDER BY book.l_name


Query B: When I put this into access it gives me a popup asking for a
value for book.deptno... If i put in a number it returns everybody in
the table, and the deptartment name who has that deptno..
This query should essentially be the same as query A, but also allow you
to search by just about anything within the same query.


SELECT book.recid,book.l_name,book.f_name,
book.mid_init,book.phone,deptnames.deptname
FROM book,deptnames
WHERE book.l_name LIKE "%house%"
OR book.f_name LIKE "%house%"
OR book.phone LIKE "%house%"
OR ((book,deptno = deptnames.deptno) AND (deptnames.deptname LIKE
"%house%") OR (deptnames.altname LIKE "%house%"))
ORDER BY book.l_name

(hope i didn't make any type-o's there... copy and past wasn't an option.)

THANKS MUCH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top