sql - Select statement with multiple, conditional, conditions -


i'm working on existing .net system , have sql table "offers" being made between 2 users. "offers" go two-ways (giggidy) usertype1 usertype2 , vice versa. make "simple" there "offertype" field defines way offer going in order correct user "accept" offer. simple enough when want query it, can execute queries quite if want data on single offer. here's problem:

i'm trying build view shows list of offers user1. in view should show offers of "offertype1" user1 "offerloginuser" , offers of "offertype2" user1 "offerrecipientuser"

offerid offerloginuserid    offerrecipientuserid    offertype 1       1                   2                       1 2       2                   1                       2 3       1                   3                       1 4       3                   1                       2 5       3                   4                       2 

i need able see offerid's: 1;2;3;4 not 5 since user1 isn't involved. @ initial glance looks simple enough, have user ids, thing is, designer of system chose use separate tables user ids based on usertype may have 2 users same id.

i have 2 select statements:

select * tbl_offers offertype = 1 , offerloginuserid = 1 

and

select * tbl_offers offertype = 2 , offerrecipientid = 1 

each executed separately give me need, possible join them , show results or have join? i'm binding these results devexpress grid display user when logged in.

this you?

select * tbl_offers (offertype = 1 , offerloginuserid = 1) or (offertype = 2 , offerrecipientid = 1) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -