Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:18:08+00:00 2026-06-08T15:18:08+00:00

My SQL statement looks like that SELECT qe.id, qe.content, a.id, a.content, a.addDT, acr.checked, acr.score

  • 0

My SQL statement looks like that

SELECT qe.id, qe.content, a.id, a.content, a.addDT, acr.checked, acr.score  
FROM `questions_and_exercises` qe, 
`questions from-to` qft 
LEFT JOIN `questions-answers` qa ON (qa.qid=qe.id AND qa.uid=qft.uid) 
LEFT JOIN answers a ON (a.id=qa.aid) 
LEFT JOIN `answer_chk_results` acr ON (acr.aid=a.id)
AND qft.to_lid=2 
WHERE qft.to_uid=3 

Now, WHEREpart is not doing what I want. Trying to achieve this result:

  • Select all where qft.to_lid=? (it means qft.to_uid=NULL) (ALWAYS)
  • If there are rows where qft.to_uid=? (it means qft.to_lid=NULL) select them too (ONLY IF THERE ARE SUCH ROWS). In other words append to result.

Is there anyway to achieve this byu only one sql statement?

update

enter image description here

For ex when I query

WHERE qft.to_lid=2 AND qft.to_uid=NULL
WHERE qft.to_uid=2 AND qft.to_lid=NULL

I want to get rows with ids: 4,5,6 . If one of this where conditions has no result show other one. In other words this conditions has no relationship between each other

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:18:10+00:00Added an answer on June 8, 2026 at 3:18 pm
    SELECT qe.id, qe.content, a.id, a.content, a.dt, acr.checked, acr.score  
    FROM `questions_and_exercises` qe, 
    `questions from-to` qft 
    LEFT JOIN `questions-answers` qa ON (qa.qid=q.id AND qa.uid=?) 
    LEFT JOIN answers a ON (a.id=qa.aid) 
    AND qft.to_lid=? 
    AND qft.uid=? 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL statement that looks something like: SELECT * FROM table1 AS
I have a SQL statement that looks like: SELECT [Phone] FROM [Table] WHERE (
My SQL statement looks like that SELECT SQL_CALC_FOUND_ROWS q.id, q.question, sb.subject, c.chapter, sc.section, p.paragraph
So I've got a SQL statement that pared down looks something like this: SELECT
I have a SQL statement like the following: select A from table1, (select B
i am new to access sql and i built a select statement that looks
I'm trying to create sql statement in TSQL that looks like this: INSERT INTO
I have LINQ statement that looks like this: return ( from c in customers
So I have an SQL statement looks like this SELECT T1.NAME, COUNT(T2.VALUE) AS numInstances
I have a SQL Statement that works as I want. select COUNT(*), MIN(emailed_to)from email.email_archive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.