2 Replies - 902 Views - Last Post: 29 October 2007 - 01:56 PM Rate Topic: -----

#1 James Bond C++ Spy  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 132
  • Joined: 03-October 07

SQL Question

Post icon  Posted 29 October 2007 - 01:24 PM

I am having a problem with this SQL.

select cast(emp_first_name as char(12)) as 'First Name', cast (emp_last_name as char(12)) as 'Last Name', emp_salary as 'Salary', emp_gender as 'Gender', emp_dpt_number as 'Dept Number' from employee

where emp_dpt_number = '3' or emp_gender = 'M' and emp_salary > 40000

Why is it returning results with less than 40000. The problem reads salary more that 40000 and gender male or dept number 3.

Thanks for any help

Is This A Good Question/Topic? 0
  • +

Replies To: SQL Question

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: SQL Question

Posted 29 October 2007 - 01:34 PM

I don't see anything marking which table you're selecting the data from, could that be part of the issue?

Also, try this:
where (empty_dtp_number = '3' or emp_gender = 'M') and emp_salary > 40000


Was This Post Helpful? 0
  • +
  • -

#3 James Bond C++ Spy  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 132
  • Joined: 03-October 07

Re: SQL Question

Posted 29 October 2007 - 01:56 PM

Thanks for the help it was the ( )'s around the OR. Once again thanks for the help and quick reply :^:

James Bond C++ Spy
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1