# What does \<\> mean in a sql query?

**URL:** <https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417>\
**Category:** Rails\
**Created:** [September 4, 2010, 8:06pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417 "2010-09-04T20:06:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [September 4, 2010, 8:06pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417/1 "2010-09-04T20:06:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [September 4, 2010, 9:49pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417/2 "2010-09-04T21:49:52Z")

</div>

Fernando P. wrote:

> !=

Thanks… The reason I didn’t think that is what it meant (although I  
believe you 🙂 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?

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [September 4, 2010, 11:27pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417/3 "2010-09-04T23:27:57Z")

</div>

> Do you understand what it means?

It’s probably a validates\_uniqueness\_of that adds that additional query.

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417/4 "2010-09-06T16:39:56Z")

</div>

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

not equals

---

<div class="post-metadata">

**Author:** ![pitosalas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a4c791/32.png) [@pitosalas](https://www.ruby-forum.com/u/pitosalas)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/what-does-mean-in-a-sql-query/194417/5 "2010-09-06T16:39:39Z")

</div>

On 4 September 2010 20:49, Pito S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Fernando P. wrote:
> 
> > !=
> 
> Thanks… The reason I didn’t think that is what it meant (although I  
> believe you 🙂 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
