-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,022
  • 3
  • 19
  • 36

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,336
  • 2
  • 34
  • 48
AK47
  • 3,599
  • 3
  • 16
  • 35
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
  • 1,998
  • 13
  • 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
  • 678
  • 3
  • 12