How to use NOT EQUAL symbol in php

Actually i am doing

SELECT * FROM position_master
inner join targets on position_master.position_id != targets.position_id

but it shows null value only…?

what i did wrong…?

You cant do a join on columns that do not equal each other. Remove the exclamation point.

SELECT * FROM position_master
inner join targets on position_master.position_id = targets.position_id;

Since the ID columns are the same name you can also use USING

SELECT * FROM position_master
inner join targets USING (position_id);

This is NOT PHP ! It is MySQL…

The exclamation character is used in PHP for NOT, but, in MySQL (queries) you have to write it in a different way. You would either use <> which is not-equal in a query or use not-in and a second select clause.

So, SELECT * FROM position_master
inner join targets on position_master.position_id <> targets.position_id

Joining columns that do not equal the columns of a ON clause??? Please provide anything that supports such a thing.

Sorry, Kev, I’m brain-dead today! You would need to do something like this, I think!
( Assuming he wants all of the master items not in the targets table… )

SELECT * FROM position_master 
  WHERE position_id NOT IN (SELECT position_id FROM targets)

But, you are the master coder for this type of thing, not me! Always bow to you on these!
Sorry, I read the entire post this time! Ha!

LOL! I knew it was a simple brain fade.:grinning:

thank you      

Sponsor our Newsletter | Privacy Policy | Terms of Service