Question

I have 3 tables.

user:

username_id varchar
password varchar

post:

user_id varchar
Threads_id int

Threads:

who_id auto increment int
title
Thread
catagory
username_id references to post.user_id
who_id references to post.Threads_id

I want to get the data from user.username and all datas from Threads table where catagory = specific conditition. How to write the query for this condition?

Was it helpful?

Solution

You can use JOIN to get the data. I have used few fields in the select you can specify what ever you need in the select list

    select
    u.username,
    t.title,
    t.Thread,
    t.catagory
    from 
    post p
    join user u on u.username_id = p.user_id
    join Threads t on t.who_id = p.Threads_id
    where t.catagory = 'some specific category'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top