on 2020 Sep 23 7:48 AM
Hi experts,
I would like to create a query that combines two (sub-)sql queries depending on their result.
The first one returns a single value, lets say valtxt = 'A', but also can be null (if the record does not exist fot the ).
SELECT valkey FROM mxi_AttrValueHelp WITH(NOLOCK) WHERE valkey IN (SELECT avalue FROM idmv_value_basic WITH(NOLOCK) WHERE attrname = 'MX_USERTYPE' AND mskey = ?? )
The second sql returns all possible values (e.g. 'A', 'B', 'C',..).
SELECT valkey FROM mxi_AttrValueHelp WITH(NOLOCK) WHERE valid = 'MX_USERTYPE'
So, if the first sql returns no value, the complete list from second sql should be returned otherwise only the result of first sql. I've played with JOINs, ISNULL, EXISTS and also UNION.. but I don't get it working.. >_<
Please help
Regards, Richard
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.