Jump to content

Need Explanation And Help


yuxian25
 Share

Recommended Posts

Hi guys, i am attached to a property company. Recently i wish to extract data to find agents who has received more than the minimum percent commission. The table AGENT has 5% as the minimum percent commissionI do the following statement Select agent_ID from AGENT where percent > 5; and it failed. May i know why?Secondly, why the NOT IN and <>ANY(not equal any) do not have the same effect, however <>ALL is equivalent to NOT IN.. why is that so? :)

Link to comment
Share on other sites

There are a number of reasons. What is the data type for the column percent? If it isn't INT, then you need quotes around the 5.

Link to comment
Share on other sites

$result = mysql_query ("SELECT agent_ID FROM agent WHERE percent > 5") or die(mysql_error());$rownum = mysql_num_rows ($result);$i = 0;// Echo resultswhile ($i < $rownum) {   $agent_id = mysql_result($result,$i,'agent_ID');   echo "<br>Agent ID is $agent_id";   $i++;}

Try this out - hope it helps!If you have any errors please post them here.

Link to comment
Share on other sites

That's PHP code by the way, that's only going to work if this is a web application using PHP with a MySQL database. I don't think MySQL has an ANY operator, so I don't think you're using MySQL (let alone PHP).

I do the following statement Select agent_ID from AGENT where percent > 5; and it failed. May i know why?
What was the error message?
however <>ALL is equivalent to NOT IN
They're not equivalent, <>ALL means that the scalar value does not equal every value in the set. NOT IN means that the value is not in the set. <>ANY should match the same things that NOT IN matches, because NOT IN will be true if the value does not appear in the set, and <>ANY will also be true if the value does not appear in the set.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...