October 24, 2003 at 4:52 am
I need to exclude records from a query result set if the creator of the record has marked a record as private (via a field called USAGE_CODE) when a users_id does not match the creator_id (user_id is used to populate the creator_id field).
If the query is done by the user_id that is equal to the creator_id, the "private" images should be included in the query result set, otherwise they do should not be included in the query result set.
Visual FoxPro SQL code premits an "immediate if" to be included in the query code; does SQL Server also permit immediate ifs?
If not, how is this kind of conditional query handled?
Thanks for any advice...
Arden
October 24, 2003 at 9:21 am
Try this.
select *
from <table>
where creator_id=(select uid from sysusers where name=user)
or usage_code=0 -- where 0 means it is not private
October 24, 2003 at 9:55 am
Need to study your code more closely and learn, but the SQL code that I implemented turned out to be quite simple
SELECT * FROM IMS
WHERE ALBUM_ID = #mALBUM_ID#
AND COLLECTION_ID = #mCOLL_ID#
AND (CREATE_BY = '#mUSER_ID#'or USAGE_CODE <> 'P')
The last line is what I ended up adding to what I had before. Before all users could see all images. Now those tagged as private can only be seen by their creator.
Arden
October 24, 2003 at 10:00 am
Looks like the same thing to me. Your query just has a few additional clauses.
October 27, 2003 at 7:10 am
check out "CASE" in BOL
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply