找到所有在18岁之前购买汽车的用户

时间:2018-01-15 19:33:52

标签: ruby-on-rails postgresql ruby-on-rails-3 ruby-on-rails-5

我想找到所有在18岁之前购买汽车的用户。

我需要这样的查询:

Option Explicit

Sub ShowOtherUserCalFolders1()

    Dim CalendarFolder As Folder
    Dim oItems As items
    Dim currFolder_entryID As String

    ' Walk the folder tree to the applicable folder

    ' Right click on folder | Properties
    '  General Tab | Location
    '   \\Highest level name of shared Boardrooms\subfolder

    Set CalendarFolder = Session.folders("Highest level name of shared Boardrooms")
    Set CalendarFolder = CalendarFolder.folders("subfolder")
    Set CalendarFolder = CalendarFolder.folders("boardroom name")

    Set ActiveExplorer = CalendarFolder
    Set oItems = CalendarFolder.items
    MsgBox CalendarFolder & " has " & oItems.count & " items"

End Sub

如何使用Postgresql在Rails 5中编写这样的查询?谢谢

1 个答案:

答案 0 :(得分:0)

尝试以下

@IBAction func unwind(segue: UIStoryboardSegue) {
    viewController?.dismiss(animated: true)

    self.performSegue(withIdentifier: "unwindToMap", sender: self)

}  

override func viewDidLoad() {
    super.viewDidLoad()

    //Check for Location Services
    if (CLLocationManager.locationServicesEnabled()) {
        myLocationManager = CLLocationManager()
        myLocationManager.delegate = mapViewDelegate as? CLLocationManagerDelegate
        myLocationManager.desiredAccuracy = kCLLocationAccuracyBest
        myLocationManager.requestAlwaysAuthorization()
        myLocationManager.requestWhenInUseAuthorization()
    }
    mapViewDelegate = searchBox.text as? MKMapViewDelegate
}

@IBAction func searchButtonClick(_ sender: Any) {


    let location = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
    let span = MKCoordinateSpanMake(0.005, 0.005)
    let region = MKCoordinateRegion(center: location, span: span)
    let annotation = MKPointAnnotation()


    annotation.coordinate = location
    annotation.title = searchBox.text!


    /*
    //find the words
    let _ : UITextPosition = searchBox.beginningOfDocument
    let _ : UITextPosition = searchBox.endOfDocument
    let _ : UITextRange = searchBox.selectedTextRange!

    // Get cursor position
    if let selectedRange = searchBox.selectedTextRange {
        _ = searchBox.offset(from: searchBox.beginningOfDocument, to: selectedRange.start)
    }
    searchBox.selectedTextRange = searchBox.textRange(
        from: searchBox.beginningOfDocument,                                         to: searchBox.endOfDocument)
    */

    // myMapView.add(location as! MKOverlay)
    myMapView.addAnnotation(annotation)
    myMapView.setRegion(region, animated: true)


}

确保数据库列User.includes(:car).where( 'cars.bought_at < ?', user.birthday + 18.years) bought_atbirthday格式。

希望能提供帮助