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 8153971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:11:25+00:00 2026-06-06T16:11:25+00:00

I tried with this query but no luck : SELECT tr.transferfrom, tr.transferto, br.id as

  • 0

I tried with this query but no luck :

SELECT tr.transferfrom, tr.transferto, br.id as 'BR_ID',
  tr.refno, br.name as 'BR_NAME', br.code as 'BRANCH_CODE',
  tr.docno, tr.transdate, stk.stockno,stk.salescat,tr.qty,
  tr.sprice,tr.qty*tr.sprice as 'GROSS_SALES' 
FROM TRANSFER tr 
JOIN branch br on tr.branchid=br.id 
JOIN stocks stk on tr.stockid=stk.id 
WHERE (tr.docno = 'ST00576' AND br.id IN ('*')) 
OR RIGHT(tr.refno,7) = 'ST00576' AND LEFT(tr.refno,3) IN ('*')

I wanted to have query to select ALL records if the br.id is a blank value.

  • 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-06T16:11:27+00:00Added an answer on June 6, 2026 at 4:11 pm

    Have a subquery that gets all the branch ids and then the IN query can refer to the output of the subquery.. the subquery will be like select br.id from branch br

    Thus the entire query will look like:

    SELECT 
      tr.transferfrom, 
      tr.transferto, 
      br.id as 'BR_ID',
      tr.refno,
      br.name as 'BR_NAME', 
      br.code as 'BRANCH_CODE', 
      tr.docno,
      tr.transdate, 
      stk.stockno,
      stk.salescat,
      tr.qty,
      tr.sprice,
      tr.qty*tr.sprice as 'GROSS_SALES' 
    FROM TRANSFER tr 
      JOIN branch br 
        on tr.branchid=br.id 
      JOIN stocks stk 
        on tr.stockid=stk.id
    WHERE (
      tr.docno = 'ST00576' 
      AND br.id IN (select br.id from branch br)
      ) 
      OR RIGHT(tr.refno,7) = 'ST00576' 
      AND LEFT(tr.refno,3) IN ( select br.id from branch br)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need query to get data between two days.I tried with this.But it gives
Having tried this query a million different ways, I can't seem to SELECT 'count_lonely_vehicles'
This code is what i have tried to process the query, either delete or
my code is this, $query = SELECT * FROM `cars` WHERE (color LIKE '%.
In SQL Server, I have this query SELECT DISTINCT City FROM Person.Address But this
I have this MySQL query: SELECT DISTINCT hours.project_id , projects.name , sum(hours.spent_hours) AS expr1
I tried to execute this query and i can´t understand what´s wrong with it.
I keep getting this error when I tried to execute this query, although I
I am tired to find out why this simple query not working. SELECT image_url
I tried this here: http://jsfiddle.net/92HXT/1/ but it does not work. It only works if

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.