I’ve never needed to perform complex queries with MySQL before (just basic SELECT,UPDATE, and DELETEs) and so I’m finding this a bit tough. This is about as hard as it will get for the script I’m writing and would appreciate some guidance.
Taking this query:
SELECT * FROM submissions ORDER BY program,title ASC
This will order the results alphabetically by program, then title. But what if program was an integer that is the id of a row’s column inside a table named programs (which also contains a column program_title). So really what I want is to do something like this:
SELECT * FROM submissions ORDER BY (SELECT program_title FROM programs WHERE id=<program id stored in submissions>),title ASC
But program_title is stored in another table. How would I go about doing this? Normally I would put things aside and study up on the subject, but as I said, it’s about as hard as things will get for now and I just need some quick guidance.
Update
Just fixed a problem inside the second query.
In the spirit of your attempt:
I just substituted
<program id stored in submissions>forprogram.