sql - Need multiple rows with same value IN OPERATOR -
suppose, order_id
4646
, 4647
, 4648
same customer.
select customer_id orders order_id in (4646, 4647, 4648)
result:
customer_id 2589 2589 2589
every customer has gcm_registration_token
.
select gcm_registration_token customer_details customer_id in (2589, 2589, 2589)
result:
gcm_registration_token dyb_phrhddu:apa91bgabuxailhumh2xyk0pwm3on37o_mtf7g...
i want second query return 3 rows same gcm_registration_token
.
expected result:
gcm_registration_token dyb_phrhddu:apa91bgabuxailhumh2xyk0pwm3on37o_mtf7g... dyb_phrhddu:apa91bgabuxailhumh2xyk0pwm3on37o_mtf7g... dyb_phrhddu:apa91bgabuxailhumh2xyk0pwm3on37o_mtf7g...
a way around fire query each value. but, possible single query.
you can use inner join in following:
select gcm_registration_token orders o inner join customer_details d on o.customer_id = d.customer_id order_id in (4646, 4647, 4648)
Comments
Post a Comment