All Stack Exchange posts display a section for "Linked" Questions to the right - which display questions whose references are added somewhere in the current post.
I would like to query a list of questions that have links to questions that are posted by me or by a specific user_id.
You can use the query below to get what you want. The query finds all question type posts that have a link to a specific user's question in the "Linked" section. Just specify the UserId to check.
p.s. The penultimate column is the link to the question that is used in the "Linked" section. The last column is the link to the question in which this is used.
WITH user_questions AS (
SELECT
Id
FROM
Posts
WHERE
PostTypeId = 1
AND OwnerUserId = ##UserId:int##
)
SELECT
*,
PostId AS [Post Link],
RelatedPostId AS [Post Link]
FROM
PostLinks
WHERE
EXISTS (
SELECT
1
FROM
user_questions
WHERE
user_questions.Id = PostLinks.PostId
AND LinkTypeId = 1
)
ORDER BY
CreationDate DESC
;