aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorTom Copeland <tom.copeland@livingsocial.com>2016-04-21 16:02:05 -0400
committerTom Copeland <tom.copeland@livingsocial.com>2016-04-21 17:19:45 -0400
commite1a31f51f4a647d1b7c98cbc84b00784d7ef214b (patch)
treeb59f34e419746fc4644f3556887185c1b071572a /guides
parentf0a2edc7fc0874b98ab6d4dbfaadc1832451c742 (diff)
downloadrails-e1a31f51f4a647d1b7c98cbc84b00784d7ef214b.tar.gz
rails-e1a31f51f4a647d1b7c98cbc84b00784d7ef214b.tar.bz2
rails-e1a31f51f4a647d1b7c98cbc84b00784d7ef214b.zip
Add SQL examples for equality and NOT [ci skip]
Diffstat (limited to 'guides')
-rw-r--r--guides/source/active_record_querying.md16
1 files changed, 13 insertions, 3 deletions
diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md
index e9f6275e55..9a13e3bda7 100644
--- a/guides/source/active_record_querying.md
+++ b/guides/source/active_record_querying.md
@@ -472,6 +472,12 @@ NOTE: Only equality, range and subset checking are possible with Hash conditions
Client.where(locked: true)
```
+This will generate SQL like this:
+
+```sql
+SELECT * FROM clients WHERE (clients.locked = 1)
+```
+
The field name can also be a string:
```ruby
@@ -517,13 +523,17 @@ SELECT * FROM clients WHERE (clients.orders_count IN (1,3,5))
### NOT Conditions
-`NOT` SQL queries can be built by `where.not`.
+`NOT` SQL queries can be built by `where.not`:
```ruby
-Article.where.not(author: author)
+Client.where.not(locked: true)
```
-In other words, this query can be generated by calling `where` with no argument, then immediately chain with `not` passing `where` conditions.
+In other words, this query can be generated by calling `where` with no argument, then immediately chain with `not` passing `where` conditions. This will generate SQL like this:
+
+```sql
+SELECT * FROM clients WHERE (clients.locked != 1)
+```
Ordering
--------