-1

I have two tables like

shopping_cart_table and customer_table

shopping_cart_table has fields shoppingcart_id | home_No|

customer_table has fields shoppingcart_id | status| customer_type|

I want to get the home_No from shopping_cart_table WHERE (customer_table.status is null OR customer_table.status='Y') AND customer_table.customer_type='X'

both table can join from shoppingcart_id

user2771655
  • 1,052
  • 3
  • 20
  • 38

3 Answers3

1

Actually this is just basic. You can use join & put where conditions.

Select a.home_No
  from shopping_cart_table as a
 inner join customer_table as b
    on a.shoppingcart_id = b.shoppingcart_id
 where nvl(b.status,'Y') = 'Y'
   and customer_type='X'
crowne
  • 8,456
  • 3
  • 35
  • 50
AK47
  • 3,707
  • 3
  • 17
  • 36
0

You can try this query:

SELECT sct.home_no 
FROM shopping_cart_table AS sct
, customer_table AS ct 
WHERE sct.shoppingcart_id = ct.shoppingcart_id 
AND (
  ct.status IS NOT NULL 
  OR ct.status = 'Y') 
AND ct.customer_type = 'X'
Captain
  • 2,148
  • 15
  • 13
0
select home_No 
from shopping_cart_table, customer_table
WHERE shopping_cart_table.shoppingcart_id = customer_table.shoppingcart_id
AND(customer_table.status is not null OR customer_table.status='Y') AND       
customer_table.customer_type='X' 

But this condition looks a bit strange:

(customer_table.status is not null OR customer_table.status='Y')

Maybe you'd want to change it for

nvl(customer_table.status,'Y')='Y'

aqssuming that 'not' was put there by a mistake

Dmitry Grekov
  • 688
  • 3
  • 12