My sql experience is a bit limited, but my Rails is on point.
I’m writing this raw sql :
select payments.payment_number as payment_payment_number, jobs.job_number from payments;
But getting this error :
ERROR 1054 (42S22): Unknown column 'jobs.job_number' in 'field list'
I don’t quite understand what my App is lacking in order to get this properly working. Can someone explain to me in Rails, what I would need to do in order to associate these two data points?
You simply have not
JOINed in thejobstable. In order to make use of two tables, you must include both of them in yourFROMclause and supply the appropriateJOINconditions in anONclause.Substitute the correct column relationship names between
paymentsandjobs. I’ve usedjob_numberas the column name in both tables.