I would like some help wth an SQL query to link posts with categories

You need to JOIN the term tables with the posts table, something like this:

SELECT
    p.post_name,
    p.post_content,
    t.name
FROM wp_posts p
JOIN wp_term_relationships tr ON ( tr.object_id = p.ID )
JOIN wp_term_taxonomy tt ON ( tt.term_taxonomy_id = tr.term_taxonomy_id )
JOIN wp_terms t ON ( t.term_id = tt.term_id )
WHERE
    p.post_type="post"
AND
    p.post_status="publish"
AND
    tt.taxonomy = 'category'

Let me know if you have any questions!