techques
asked on
How to write SQL with and or
Hi
I have a query need to select the result with
transactiontypeid = 1,2,3,4 and status=0 and alltranid=0
But, the following query select status=1 and alltranid=1
How should i solve it?
I have a query need to select the result with
transactiontypeid = 1,2,3,4 and status=0 and alltranid=0
But, the following query select status=1 and alltranid=1
How should i solve it?
select [id]=t.id, [alltranid], [transactiontypeid], [type]=r.type, [clientid]=t.clientid, [nickname]=c.nickname, [currency]=t.currency, [ucurrency]=u.currency,[status]
from alltransaction t inner join client c on t.clientid = c.id
inner join currency u on t.currency = u.currency
inner join transactiontype r on t.transactiontypeid = r.id
where alltranid = 0 and status=0 and transactiontypeid=1 or transactiontypeid=2
or transactiontypeid=3 or transactiontypeid=4
order by [id] desc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window