how to do in console

12 views
Skip to first unread message

Fahim Patel

unread,
Sep 12, 2012, 7:56:22 AM9/12/12
to rubyonra...@googlegroups.com


i wish to select id from table where name = 'fahim'
Table name is Info  and columns are id and name

how to write a query in console 

Kashif Umair Liaqat

unread,
Sep 12, 2012, 8:17:28 AM9/12/12
to rubyonra...@googlegroups.com
If you are talking about the console of MySQL query then you can write as below.

SELECT id FROM Info WHERE name = 'fahim'

Else if you are talking about the ActiveRecord Query in rails then write it like this.

Info.select("id").where(:name => "fahim")
This query would return you the ActiveRelation object containing the ids from Info where name is fahim. 
Reply all
Reply to author
Forward
0 new messages