What does <> mean in a sql query?

This is from the rails log:

SELECT “district_sets”.id FROM “district_sets” WHERE
(“district_sets”.“ident” = ‘juris-60c8bcea56c0dfa02d121691e0e72152’ AND
“district_sets”.id <> 12) LIMIT 1

I am confused by the <> operator. Can anyone clarify that for me please?
Thanks!

– Pito

Fernando P. wrote:

!=

Thanks… The reason I didn’t think that is what it meant (although I
believe you :slight_smile: is that I saw it here:

[Development]>> ap j
#DistrictSet:0x105568550 {
:id => 3,
:display_name => “ds2”,
:created_at => Sat, 04 Sep 2010 11:21:36 PDT -07:00,
:updated_at => Sat, 04 Sep 2010 11:21:36 PDT -07:00,
:secondary_name => nil,
:icon_file_name => nil,
:icon_content_type => nil,
:icon_file_size => nil,
:icon_updated_at => nil,
:descriptive_text => nil,
:ident => “juris-a88e89de29712642eaef324fd9bc03ed”
}
=> nil

in other words, j is assigned a DistrictSet object, that has j.id = 3

[Development]>> j.save!
DistrictSet Load (0.3ms) SELECT “district_sets”.id FROM
“district_sets” WHERE (“district_sets”.“ident” =
‘juris-a88e89de29712642eaef324fd9bc03ed’ AND “district_sets”.id <> 3)
LIMIT 1
[paperclip] Saving attachments.
=> true

And when I ask activerecord to save it, I see the very odd <> 3.

Do you understand what it means?

Do you understand what it means?

It’s probably a validates_uniqueness_of that adds that additional query.

http://dev.mysql.com/doc/refman/5.0/en/non-typed-operators.html

not equals

On 4 September 2010 20:49, Pito S. [email protected] wrote:

Fernando P. wrote:

!=

Thanks… The reason I didn’t think that is what it meant (although I
believe you :slight_smile: is that I saw it here:

[Development]>> ap j
#DistrictSet:0x105568550 {
:id => 3,
:display_name => “ds2”,
:created_at => Sat, 04 Sep 2010 11:21:36 PDT -07:00,
:updated_at => Sat, 04 Sep 2010 11:21:36 PDT -07:00,
:secondary_name => nil,
:icon_file_name => nil,
:icon_content_type => nil,
:icon_file_size => nil,
:icon_updated_at => nil,
:descriptive_text => nil,
:ident => “juris-a88e89de29712642eaef324fd9bc03ed”
}
=> nil

in other words, j is assigned a DistrictSet object, that has j.id = 3

[Development]>> j.save!
DistrictSet Load (0.3ms) SELECT “district_sets”.id FROM
“district_sets” WHERE (“district_sets”.“ident” =
‘juris-a88e89de29712642eaef324fd9bc03ed’ AND “district_sets”.id <> 3)
LIMIT 1
[paperclip] Saving attachments.
=> true

And when I ask activerecord to save it, I see the very odd <> 3.

Do you understand what it means?

I may be wrong but have you got a validates_uniqueness_of on ident?
That query could be checking to see if there is already a matching
ident. The id<>3 could be so that it does not find the one you are
updating or creating.

Colin