i am trying to display some data about a specific id and THATS where the WHERE Clause comes in place, but it doens’t work.
By the way in wp_posts the user_id is the wp_users.ID.
SELECT wp_users.ID, post_name FROM wp_users
LEFT JOIN wp_posts
ON wp_users.ID = user_id
ORDER BY wp_users.ID
WHERE wp_users.ID="2"
This works and displays the wp_users.ID and post_name but if i want to display only the post_names of a specific ID with this line ‘WHERE wp_users.ID="2"’ it doesn’t work.
New to MySQL
2
Answers
Nevermind it works now
I’ll try to fix the query for you, in some way that makes sense to me:
Assuming:
table wp_users(ID,…) ID is Primary key
table wp_posts(ID, user_id,…) ID is Primary key and user_id is foreign key references wp_users(ID)
A and B are alias… I alwais use them (and DBMS also loves them).
Hope it helps